From 11a2e49a5f57191156c9cfa6c5a485a97c0b80bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Barros=20Cabral?= Date: Thu, 7 Dec 2023 14:31:04 -0300 Subject: [PATCH] (#22) Fix trailer size --- HelloWorld.pdf | Bin 0 -> 527 bytes .../fabriciofx/cactoos/pdf/Document.java | 18 +++++++++++++++--- .../fabriciofx/cactoos/pdf/DocumentTest.java | 4 +++- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 HelloWorld.pdf diff --git a/HelloWorld.pdf b/HelloWorld.pdf new file mode 100644 index 0000000000000000000000000000000000000000..85e6bcba55236fb7e478cdb7cc863556159f7d61 GIT binary patch literal 527 zcmZXR%}&BV6ovPFinD0~i7=EuOF~$nG$v{!WfB*Z#b8GqQaWZj#Gj{e=Zg^6z62|G z`U1{O!C+|Gw6{IyyQla1Vr2IPF{_4^=H=!~Os!Lv-_ zR;nzmVleP{o?1osQ2Fx6LC%8A=_w6lsBJ+sbE#BG2>PO5Mev0hrQVW*7}aIATclGTHTo-O-r`mT=QHPXqEMtDN`QB zwCX)CG8WiTM1i|e7u&rhLsszeiHa33YO!3g9AvVdYp1f>z~n5?{nTvlJ^hO33;lp@ z)Ba7N6=y4NNL{la1id%X259Nrw>\n", - this.catalog.reference() + "trailer << /Root %s /Size %d >>\n", + this.catalog.reference(), + this.count.value() ).asString().getBytes() ); baos.write(Document.EOF.getBytes()); diff --git a/src/test/java/com/github/fabriciofx/cactoos/pdf/DocumentTest.java b/src/test/java/com/github/fabriciofx/cactoos/pdf/DocumentTest.java index 7a79dff..814e0bd 100644 --- a/src/test/java/com/github/fabriciofx/cactoos/pdf/DocumentTest.java +++ b/src/test/java/com/github/fabriciofx/cactoos/pdf/DocumentTest.java @@ -45,6 +45,7 @@ void buildDocument() { "Must represent a PDF document", new TextOf( new Document( + count, new Metadata(count, "Hello World"), new Catalog( count, @@ -84,7 +85,7 @@ void buildDocument() { "4 0 obj\n<< /Type /Page /Resources 2 0 R /Contents 3 0 R /Parent 5 0 R >>\nendobj", "2 0 obj\n<< /Font << /F1 << /Type /Font /BaseFont /Times-Roman /Subtype /Type1 >> >> >>\nendobj", "3 0 obj\n<< /Length 62 >>\nstream\nBT /F1 18 Tf 0 0 Td (Hello World with \\(, \\), \\\\ and \\r) Tj ET\nendstream\nendobj", - "trailer << /Root 6 0 R /Size 6 >>", + "trailer << /Root 6 0 R /Size 7 >>", "%%%%EOF" ) ) @@ -99,6 +100,7 @@ void buildFile() throws Exception { Files.write( file.toPath(), new Document( + count, new Metadata(count, "Hello World"), new Catalog( count,