Skip to content

Commit

Permalink
Features: Add method to validate if new line fits the current page (#404
Browse files Browse the repository at this point in the history
)

* feat: add method to validate if new line fits the current page

* test: test creation to validate routine FitlnCurrentPage

* docs: example update

* test: test name standardization
  • Loading branch information
Fernando-hub527 authored Mar 20, 2024
1 parent 3079724 commit 1967428
Show file tree
Hide file tree
Showing 80 changed files with 577 additions and 978 deletions.
Binary file modified docs/assets/pdf/addpagev2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/backgroundv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/barcodegridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/billingv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/cellstylev2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/compressionv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/customdimensionsv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/customfontv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/custompagev2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/datamatrixgridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/disablepagebreakv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/footerv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/headerv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/imagegridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/linegridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/listv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/marginsv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/maxgridsumv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/mergepdfv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/metadatasv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/orientationv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/pagenumberv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/parallelismv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/protectionv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/qrgridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/signaturegridv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/simplestv2.pdf
Binary file not shown.
Binary file modified docs/assets/pdf/textgridv2.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/assets/text/addpagev2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 5.50ms, executions: [5.50ms]
add_page -> avg: 2815.00ns, executions: [2.81μs]
generate -> avg: 19.23ms, executions: [19.23ms]
add_page -> avg: 8937.00ns, executions: [8.94μs]
file_size -> 5.64Kb
4 changes: 2 additions & 2 deletions docs/assets/text/backgroundv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 549.78ms, executions: [549.78ms]
add_page -> avg: 1731.00ns, executions: [1.73μs]
generate -> avg: 1267.26ms, executions: [1267.26ms]
add_page -> avg: 6442.00ns, executions: [6.44μs]
file_size -> 897.39Kb
4 changes: 2 additions & 2 deletions docs/assets/text/barcodegridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 1.21ms, executions: [1.21ms]
add_row -> avg: 218.00ns, executions: [652.00ns, 173.00ns, 105.00ns, 63.00ns, 97.00ns]
generate -> avg: 6.20ms, executions: [6.20ms]
add_row -> avg: 805.40ns, executions: [1.79μs, 0.62μs, 0.56μs, 0.39μs, 0.66μs]
file_size -> 16.01Kb
10 changes: 5 additions & 5 deletions docs/assets/text/billingv2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generate -> avg: 22.37ms, executions: [22.37ms]
header -> avg: 298.00ns, executions: [298.00ns]
footer -> avg: 62.00ns, executions: [62.00ns]
add_row -> avg: 182.00ns, executions: [147.00ns, 217.00ns]
add_rows -> avg: 206.00ns, executions: [113.00ns, 299.00ns]
generate -> avg: 82.88ms, executions: [82.88ms]
header -> avg: 1.07μs, executions: [1.07μs]
footer -> avg: 291.00ns, executions: [291.00ns]
add_row -> avg: 396.00ns, executions: [341.00ns, 451.00ns]
add_rows -> avg: 560.50ns, executions: [200.00ns, 921.00ns]
file_size -> 231.70Kb
4 changes: 2 additions & 2 deletions docs/assets/text/cellstylev2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 15.25ms, executions: [15.25ms]
add_rows -> avg: 75.08ns, executions: [0.26μs, 0.11μs, 0.09μs, 0.02μs, 0.08μs, 0.02μs, 0.02μs, 0.02μs, 0.07μs, 0.02μs, 0.02μs, 0.02μs, 0.03μs, 0.02μs, 0.02μs, 0.02μs, 1.80μs, 0.02μs, 0.01μs, 0.02μs, 0.03μs, 0.02μs, 0.01μs, 0.02μs, 0.02μs, 0.01μs, 0.47μs, 0.07μs, 0.08μs, 0.02μs, 0.08μs, 0.02μs, 0.02μs, 0.02μs, 0.07μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.01μs, 0.01μs, 0.06μs, 0.02μs, 0.01μs, 0.01μs, 0.02μs, 0.01μs, 0.02μs, 0.01μs, 0.02μs, 0.02μs, 0.26μs, 0.06μs, 0.07μs, 0.02μs, 0.07μs, 0.02μs, 0.03μs, 0.02μs]
generate -> avg: 39.87ms, executions: [39.87ms]
add_rows -> avg: 163.28ns, executions: [1.41μs, 0.15μs, 0.13μs, 0.05μs, 0.16μs, 0.06μs, 0.05μs, 0.05μs, 0.16μs, 0.04μs, 0.04μs, 0.04μs, 0.05μs, 0.04μs, 0.03μs, 0.04μs, 0.99μs, 0.04μs, 0.04μs, 0.04μs, 0.05μs, 0.04μs, 0.05μs, 0.04μs, 0.05μs, 0.04μs, 1.46μs, 0.13μs, 0.13μs, 0.04μs, 0.62μs, 0.04μs, 0.05μs, 0.04μs, 0.42μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.05μs, 0.04μs, 0.15μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 1.65μs, 0.12μs, 0.11μs, 0.04μs, 0.12μs, 0.04μs, 0.05μs, 0.04μs]
file_size -> 28.60Kb
4 changes: 2 additions & 2 deletions docs/assets/text/compressionv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 3.62ms, executions: [3.62ms]
add_rows -> avg: 119.50ns, executions: [207.00ns, 147.00ns, 96.00ns, 28.00ns]
generate -> avg: 15.30ms, executions: [15.30ms]
add_rows -> avg: 523.25ns, executions: [1.27μs, 0.39μs, 0.32μs, 0.11μs]
file_size -> 224.69Kb
4 changes: 2 additions & 2 deletions docs/assets/text/customdimensionsv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 1.45ms, executions: [1.45ms]
add_row -> avg: 634.00ns, executions: [634.00ns]
generate -> avg: 3.72ms, executions: [3.72ms]
add_row -> avg: 4428.00ns, executions: [4.43μs]
file_size -> 205.24Kb
6 changes: 3 additions & 3 deletions docs/assets/text/customfontv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 35.21ms, executions: [35.21ms]
add_row -> avg: 134.86ns, executions: [1.14μs, 0.17μs, 0.12μs, 0.07μs, 0.12μs, 0.06μs, 0.06μs, 0.05μs, 0.11μs, 0.09μs, 0.05μs, 0.05μs, 0.06μs, 0.06μs, 0.05μs, 0.05μs, 0.15μs, 0.05μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.06μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.06μs, 0.07μs, 0.05μs, 0.24μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 2.14μs, 0.09μs, 0.08μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.11μs, 3.50μs, 0.10μs, 0.11μs, 0.06μs, 0.12μs, 0.06μs, 0.06μs, 0.05μs, 0.10μs, 0.07μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 0.09μs, 0.05μs, 0.05μs, 0.05μs, 0.81μs, 0.05μs, 0.05μs, 0.09μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.13μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.07μs, 0.05μs, 0.06μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.06μs, 0.41μs, 0.12μs, 0.13μs, 0.05μs, 0.10μs, 0.12μs]
add_rows -> avg: 64.00ns, executions: [64.00ns]
generate -> avg: 117.13ms, executions: [117.13ms]
add_row -> avg: 224.21ns, executions: [1.47μs, 0.23μs, 0.23μs, 0.13μs, 0.23μs, 0.14μs, 0.20μs, 0.45μs, 0.45μs, 0.18μs, 0.23μs, 0.11μs, 0.11μs, 0.12μs, 0.12μs, 0.11μs, 0.82μs, 0.12μs, 0.11μs, 0.13μs, 0.12μs, 0.11μs, 0.12μs, 0.16μs, 0.11μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.39μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.26μs, 0.16μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.10μs, 0.11μs, 0.13μs, 2.88μs, 0.18μs, 0.20μs, 0.12μs, 0.20μs, 0.13μs, 0.11μs, 0.11μs, 0.21μs, 0.25μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.11μs, 0.11μs, 0.27μs, 0.12μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.13μs, 0.11μs, 0.30μs, 0.12μs, 0.11μs, 0.11μs, 0.11μs, 0.11μs, 0.12μs, 0.11μs, 0.11μs, 0.13μs, 0.12μs, 0.12μs, 0.12μs, 0.11μs, 0.11μs, 0.11μs, 0.12μs, 0.12μs, 0.11μs, 0.14μs, 0.11μs, 4.54μs, 0.18μs, 0.19μs, 0.12μs, 0.19μs, 0.19μs]
add_rows -> avg: 100.00ns, executions: [100.00ns]
file_size -> 286.87Kb
4 changes: 2 additions & 2 deletions docs/assets/text/custompagev2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 927.72μs, executions: [927.72μs]
add_row -> avg: 593.00ns, executions: [593.00ns]
generate -> avg: 2.17ms, executions: [2.17ms]
add_row -> avg: 1633.00ns, executions: [1.63μs]
file_size -> 205.16Kb
4 changes: 2 additions & 2 deletions docs/assets/text/datamatrixgridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 285.39μs, executions: [285.39μs]
add_row -> avg: 164.25ns, executions: [355.00ns, 129.00ns, 91.00ns, 82.00ns]
generate -> avg: 1.16ms, executions: [1.16ms]
add_row -> avg: 618.75ns, executions: [1.42μs, 0.42μs, 0.39μs, 0.24μs]
file_size -> 4.58Kb
4 changes: 2 additions & 2 deletions docs/assets/text/disablepagebreakv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 134.47ms, executions: [134.47ms]
add_page -> avg: 292.00ns, executions: [292.00ns]
generate -> avg: 264.65ms, executions: [264.65ms]
add_page -> avg: 762.00ns, executions: [762.00ns]
file_size -> 806.50Kb
6 changes: 3 additions & 3 deletions docs/assets/text/footerv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 8.74ms, executions: [8.74ms]
footer -> avg: 154.00ns, executions: [154.00ns]
add_rows -> avg: 102.04ns, executions: [0.11μs, 0.08μs, 0.06μs, 0.03μs, 0.07μs, 0.02μs, 0.02μs, 0.02μs, 0.07μs, 0.02μs, 0.02μs, 0.01μs, 0.03μs, 0.02μs, 0.02μs, 0.02μs, 1.45μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.01μs, 0.02μs, 0.38μs, 0.08μs, 0.06μs, 0.02μs, 0.06μs, 0.01μs, 0.02μs, 0.02μs, 0.07μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.06μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 1.86μs, 0.04μs]
generate -> avg: 21.94ms, executions: [21.94ms]
footer -> avg: 831.00ns, executions: [831.00ns]
add_rows -> avg: 165.54ns, executions: [0.32μs, 0.22μs, 0.26μs, 0.10μs, 0.26μs, 0.09μs, 0.07μs, 0.06μs, 0.27μs, 0.07μs, 0.06μs, 0.07μs, 0.07μs, 0.07μs, 0.06μs, 0.06μs, 0.99μs, 0.07μs, 0.07μs, 0.07μs, 0.06μs, 0.07μs, 0.06μs, 0.07μs, 1.49μs, 0.21μs, 0.19μs, 0.07μs, 0.18μs, 0.06μs, 0.05μs, 0.05μs, 0.19μs, 0.06μs, 0.05μs, 0.06μs, 0.06μs, 0.06μs, 0.06μs, 0.06μs, 0.25μs, 0.05μs, 0.05μs, 0.05μs, 0.06μs, 0.07μs, 0.06μs, 0.06μs, 0.95μs, 0.19μs]
file_size -> 14.76Kb
6 changes: 3 additions & 3 deletions docs/assets/text/headerv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 8.87ms, executions: [8.87ms]
header -> avg: 388.00ns, executions: [388.00ns]
add_rows -> avg: 113.90ns, executions: [0.14μs, 0.08μs, 0.02μs, 0.06μs, 0.02μs, 0.02μs, 0.02μs, 0.07μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.01μs, 0.02μs, 0.01μs, 1.88μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.01μs, 0.01μs, 0.01μs, 0.03μs, 0.55μs, 0.07μs, 0.01μs, 0.07μs, 0.01μs, 0.01μs, 0.01μs, 0.05μs, 0.01μs, 0.02μs, 0.02μs, 0.02μs, 0.01μs, 0.02μs, 0.01μs, 0.06μs, 0.02μs, 0.02μs, 0.01μs, 0.02μs, 0.01μs, 0.02μs, 0.02μs, 0.02μs, 1.97μs, 0.05μs]
generate -> avg: 39.44ms, executions: [39.44ms]
header -> avg: 1.23μs, executions: [1.23μs]
add_rows -> avg: 215.20ns, executions: [0.50μs, 0.27μs, 0.12μs, 0.31μs, 0.09μs, 0.09μs, 0.09μs, 0.35μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.08μs, 0.08μs, 1.49μs, 0.06μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 2.10μs, 0.24μs, 0.07μs, 0.30μs, 0.07μs, 0.07μs, 0.06μs, 0.29μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.07μs, 0.31μs, 0.06μs, 0.06μs, 0.07μs, 0.06μs, 0.08μs, 0.08μs, 0.08μs, 0.07μs, 1.57μs, 0.24μs]
file_size -> 14.75Kb
4 changes: 2 additions & 2 deletions docs/assets/text/imagegridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 3.42ms, executions: [3.42ms]
add_row -> avg: 188.67ns, executions: [602.00ns, 139.00ns, 139.00ns, 64.00ns, 111.00ns, 77.00ns]
generate -> avg: 7.14ms, executions: [7.14ms]
add_row -> avg: 542.67ns, executions: [1.86μs, 0.33μs, 0.29μs, 0.25μs, 0.31μs, 0.21μs]
file_size -> 222.72Kb
4 changes: 2 additions & 2 deletions docs/assets/text/linegridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 163.26μs, executions: [163.26μs]
add_row -> avg: 474.60ns, executions: [1.18μs, 0.38μs, 0.29μs, 0.22μs, 0.31μs]
generate -> avg: 175.96μs, executions: [175.96μs]
add_row -> avg: 545.20ns, executions: [1.68μs, 0.32μs, 0.27μs, 0.19μs, 0.26μs]
file_size -> 2.48Kb
4 changes: 2 additions & 2 deletions docs/assets/text/listv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 33.85ms, executions: [33.85ms]
add_rows -> avg: 3465.00ns, executions: [3.46μs]
generate -> avg: 88.82ms, executions: [88.82ms]
add_rows -> avg: 3737.00ns, executions: [3.74μs]
file_size -> 48.85Kb
4 changes: 2 additions & 2 deletions docs/assets/text/marginsv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 190.56ms, executions: [190.56ms]
add_row -> avg: 333.00ns, executions: [333.00ns]
generate -> avg: 451.78ms, executions: [451.78ms]
add_row -> avg: 1383.00ns, executions: [1.38μs]
file_size -> 253.43Kb
6 changes: 3 additions & 3 deletions docs/assets/text/maxgridsumv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 7.74ms, executions: [7.74ms]
add_row -> avg: 697.50ns, executions: [1.19μs, 0.20μs]
add_rows -> avg: 312.00ns, executions: [312.00ns]
generate -> avg: 14.40ms, executions: [14.40ms]
add_row -> avg: 746.50ns, executions: [1.15μs, 0.34μs]
add_rows -> avg: 1102.00ns, executions: [1.10μs]
file_size -> 8.13Kb
8 changes: 4 additions & 4 deletions docs/assets/text/mergepdfv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 18.18ms, executions: [18.18ms]
add_rows -> avg: 138.56ns, executions: [0.59μs, 0.20μs, 0.10μs, 0.04μs, 0.19μs, 0.04μs, 0.03μs, 0.05μs, 0.21μs, 0.03μs, 0.04μs, 0.03μs, 0.03μs, 2.47μs, 0.11μs, 0.10μs, 0.03μs, 0.11μs, 0.04μs, 0.03μs, 0.03μs, 0.12μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.49μs, 0.09μs, 0.09μs, 0.03μs, 0.14μs, 0.03μs, 0.03μs, 0.03μs, 0.10μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.46μs, 0.09μs, 0.10μs, 0.03μs, 0.09μs, 0.03μs, 0.03μs, 0.04μs, 0.10μs, 0.03μs, 0.05μs]
merge_pdf -> avg: 1.37ms, executions: [1.37ms]
file_size -> 280.76Kb
generate -> avg: 22.46ms, executions: [22.46ms]
add_rows -> avg: 171.54ns, executions: [0.94μs, 0.16μs, 0.19μs, 0.07μs, 0.21μs, 0.06μs, 0.07μs, 0.06μs, 0.22μs, 0.07μs, 0.05μs, 0.05μs, 0.05μs, 1.71μs, 0.16μs, 0.16μs, 0.06μs, 0.18μs, 0.07μs, 0.05μs, 0.05μs, 0.19μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.69μs, 0.16μs, 0.15μs, 0.07μs, 0.18μs, 0.07μs, 0.05μs, 0.05μs, 0.18μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.68μs, 0.15μs, 0.16μs, 0.07μs, 0.18μs, 0.08μs, 0.05μs, 0.06μs, 0.19μs, 0.05μs, 0.06μs]
merge_pdf -> avg: 3.94ms, executions: [3.94ms]
file_size -> 280.85Kb
4 changes: 2 additions & 2 deletions docs/assets/text/metadatasv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 209.07μs, executions: [209.07μs]
add_rows -> avg: 444.00ns, executions: [444.00ns]
generate -> avg: 979.04μs, executions: [979.04μs]
add_rows -> avg: 1112.00ns, executions: [1.11μs]
file_size -> 1.30Kb
4 changes: 2 additions & 2 deletions docs/assets/text/orientationv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 208.76μs, executions: [208.76μs]
add_rows -> avg: 370.00ns, executions: [370.00ns]
generate -> avg: 602.08μs, executions: [602.08μs]
add_rows -> avg: 1032.00ns, executions: [1.03μs]
file_size -> 1.29Kb
4 changes: 2 additions & 2 deletions docs/assets/text/pagenumberv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 3.54ms, executions: [3.54ms]
add_rows -> avg: 179.73ns, executions: [0.23μs, 0.08μs, 0.07μs, 0.03μs, 0.08μs, 0.02μs, 0.02μs, 0.02μs, 0.07μs, 0.01μs, 0.01μs, 0.01μs, 0.01μs, 1.96μs, 0.06μs]
generate -> avg: 9.24ms, executions: [9.24ms]
add_rows -> avg: 980.00ns, executions: [11.97μs, 0.15μs, 0.15μs, 0.05μs, 0.22μs, 0.05μs, 0.04μs, 0.04μs, 0.19μs, 0.04μs, 0.04μs, 0.04μs, 0.04μs, 1.53μs, 0.14μs]
file_size -> 5.50Kb
6 changes: 3 additions & 3 deletions docs/assets/text/parallelismv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 9.69ms, executions: [9.69ms]
add_rows -> avg: 285.38ns, executions: [0.53μs, 0.20μs, 0.12μs, 0.05μs, 0.13μs, 0.04μs, 0.03μs, 0.03μs, 0.13μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 10.34μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.06μs, 0.03μs, 0.03μs, 0.03μs, 0.94μs, 0.13μs, 0.11μs, 0.03μs, 0.14μs, 0.03μs, 0.03μs, 0.03μs, 0.11μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.03μs, 0.04μs, 0.15μs, 0.03μs, 0.03μs, 0.03μs, 0.05μs, 0.03μs, 0.03μs, 0.03μs]
file_size -> 2.43Kb
generate -> avg: 17.51ms, executions: [17.51ms]
add_rows -> avg: 163.14ns, executions: [1.68μs, 0.21μs, 0.21μs, 0.08μs, 0.23μs, 0.05μs, 0.06μs, 0.05μs, 0.24μs, 0.05μs, 0.05μs, 0.05μs, 0.04μs, 0.05μs, 0.05μs, 0.05μs, 1.45μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 1.26μs, 0.17μs, 0.18μs, 0.06μs, 0.19μs, 0.05μs, 0.04μs, 0.05μs, 0.19μs, 0.05μs, 0.05μs, 0.04μs, 0.05μs, 0.05μs, 0.04μs, 0.05μs, 0.22μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs, 0.05μs]
file_size -> 2.52Kb
4 changes: 2 additions & 2 deletions docs/assets/text/protectionv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 308.71μs, executions: [308.71μs]
add_rows -> avg: 321.00ns, executions: [321.00ns]
generate -> avg: 1.31ms, executions: [1.31ms]
add_rows -> avg: 1473.00ns, executions: [1.47μs]
file_size -> 1.42Kb
4 changes: 2 additions & 2 deletions docs/assets/text/qrgridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 1.13ms, executions: [1.13ms]
add_row -> avg: 179.75ns, executions: [382.00ns, 163.00ns, 114.00ns, 60.00ns]
generate -> avg: 2.99ms, executions: [2.99ms]
add_row -> avg: 521.25ns, executions: [1.28μs, 0.31μs, 0.29μs, 0.20μs]
file_size -> 4.65Kb
4 changes: 2 additions & 2 deletions docs/assets/text/signaturegridv2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generate -> avg: 2.80ms, executions: [2.80ms]
add_row -> avg: 307.33ns, executions: [562.00ns, 202.00ns, 158.00ns]
generate -> avg: 6.04ms, executions: [6.04ms]
add_row -> avg: 721.33ns, executions: [1.33μs, 0.46μs, 0.37μs]
file_size -> 4.99Kb
6 changes: 3 additions & 3 deletions docs/assets/text/textgridv2.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate -> avg: 6.33ms, executions: [6.33ms]
add_row -> avg: 256.60ns, executions: [757.00ns, 236.00ns, 114.00ns, 88.00ns, 88.00ns]
add_rows -> avg: 102.40ns, executions: [179.00ns, 75.00ns, 42.00ns, 174.00ns, 42.00ns]
generate -> avg: 10.30ms, executions: [10.30ms]
add_row -> avg: 433.00ns, executions: [1.24μs, 0.34μs, 0.19μs, 0.19μs, 0.20μs]
add_rows -> avg: 140.40ns, executions: [221.00ns, 180.00ns, 60.00ns, 181.00ns, 60.00ns]
file_size -> 8.74Kb
7 changes: 7 additions & 0 deletions maroto.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func (m *Maroto) AddRow(rowHeight float64, cols ...core.Col) core.Row {
return r
}

// FitlnCurrentPage is responsible to validating whether a line fits on
// the current page.
func (m *Maroto) FitlnCurrentPage(heightNewLine float64) bool {
contentSize := m.getRowsHeight(m.rows...) + m.footerHeight + m.headerHeight
return contentSize+heightNewLine < m.config.Dimensions.Height
}

// RegisterHeader is responsible to define a set of rows as a header
// of the document. The header will appear in every new page of the document.
// The header cannot occupy an area greater than the useful area of the page,
Expand Down
29 changes: 29 additions & 0 deletions maroto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,32 @@ func TestMaroto_Generate(t *testing.T) {
assert.NotNil(t, doc)
})
}

func TestMaroto_FitlnCurrentPage(t *testing.T) {
t.Run("when component is smaller should available size, then false", func(t *testing.T) {
sut := maroto.New(config.NewBuilder().
WithDimensions(210.0, 297.0).
Build())

var rows []core.Row
for i := 0; i < 26; i++ {
rows = append(rows, row.New(10).Add(col.New(12)))
}

sut.AddPages(page.New().Add(rows...))
assert.False(t, sut.FitlnCurrentPage(40))
})
t.Run("when component is larger should the available size, then true", func(t *testing.T) {
sut := maroto.New(config.NewBuilder().
WithDimensions(210.0, 297.0).
Build())

var rows []core.Row
for i := 0; i < 10; i++ {
rows = append(rows, row.New(10).Add(col.New(12)))
}

sut.AddPages(page.New().Add(rows...))
assert.True(t, sut.FitlnCurrentPage(40))
})
}
4 changes: 4 additions & 0 deletions metricsdecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func NewMetricsDecorator(inner core.Maroto) core.Maroto {
}
}

func (m *MetricsDecorator) FitlnCurrentPage(heightNewLine float64) bool {
return m.inner.FitlnCurrentPage(heightNewLine)
}

// Generate decorates the Generate method of maroto instance.
func (m *MetricsDecorator) Generate() (core.Document, error) {
var document core.Document
Expand Down
11 changes: 11 additions & 0 deletions metricsdecorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ func TestMetricsDecorator_GetStructure(t *testing.T) {
inner.AssertNumberOfCalls(t, "AddRows", 1)
inner.AssertNumberOfCalls(t, "GetStructure", 1)
}

func TestMetricsDecorator_FitlnCurrentPage(t *testing.T) {
inner := &mocks.Maroto{}
inner.EXPECT().FitlnCurrentPage(10.0).Return(true)
inner.EXPECT().FitlnCurrentPage(20.0).Return(false)

sut := NewMetricsDecorator(inner)
// Assert
assert.True(t, sut.FitlnCurrentPage(10))
assert.False(t, sut.FitlnCurrentPage(20))
}
Loading

0 comments on commit 1967428

Please sign in to comment.