From ce60188a1766bd5e550233517d6422b5f382afad Mon Sep 17 00:00:00 2001 From: Emmeran Seehuber Date: Sat, 12 May 2018 11:55:09 +0200 Subject: [PATCH 1/4] Testcase #220 --- .../com/openhtmltopdf/testcases/TestcaseRunner.java | 2 ++ .../src/main/resources/testcases/simplerotate.html | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 openhtmltopdf-examples/src/main/resources/testcases/simplerotate.html diff --git a/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java b/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java index 7b6eaf68b..090ea8250 100644 --- a/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java +++ b/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java @@ -103,6 +103,8 @@ public static void main(String[] args) throws Exception { */ runTestCase("transform"); + runTestCase("simplerotate"); + runTestCase("quoting"); runTestCase("math-ml"); diff --git a/openhtmltopdf-examples/src/main/resources/testcases/simplerotate.html b/openhtmltopdf-examples/src/main/resources/testcases/simplerotate.html new file mode 100644 index 000000000..1b86e01a0 --- /dev/null +++ b/openhtmltopdf-examples/src/main/resources/testcases/simplerotate.html @@ -0,0 +1,10 @@ + + + + + +
+ asdasdasd +
+ + From 3a03faff0799de70f47e06b6dd760a3403095d4b Mon Sep 17 00:00:00 2001 From: Emmeran Seehuber Date: Tue, 22 May 2018 08:47:15 +0200 Subject: [PATCH 2/4] Try to preserve existing outlines if the document had already one. (cherry picked from commit 93bc44a) --- .../com/openhtmltopdf/pdfboxout/PdfBoxOutputDevice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxOutputDevice.java b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxOutputDevice.java index f4a682481..12eac0fb6 100644 --- a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxOutputDevice.java +++ b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxOutputDevice.java @@ -1056,8 +1056,11 @@ private void writeOutline(RenderingContext c, Box root) { if (_bookmarks.size() > 0) { // TODO: .setViewerPreferences(PdfWriter.PageModeUseOutlines); - PDDocumentOutline outline = new PDDocumentOutline(); - _writer.getDocumentCatalog().setDocumentOutline( outline ); + PDDocumentOutline outline = _writer.getDocumentCatalog().getDocumentOutline(); + if (outline == null) { + outline = new PDDocumentOutline(); + _writer.getDocumentCatalog().setDocumentOutline(outline); + } writeBookmarks(c, root, outline, _bookmarks); } From 1319ded95f803c228a93c481b1966b60f34cde22 Mon Sep 17 00:00:00 2001 From: Emmeran Seehuber Date: Tue, 22 May 2018 08:48:12 +0200 Subject: [PATCH 3/4] #80 Example how to output different HTML files into the same PDF document. (cherry picked from commit e7daf36) --- .../testcases/TestcaseRunner.java | 2 +- .../testcases/FSPageBreakMinHeightSample.html | 10 +++- .../testcases/ConcateOutputTest.java | 59 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 openhtmltopdf-examples/src/test/java/com/openhtmltopdf/testcases/ConcateOutputTest.java diff --git a/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java b/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java index 090ea8250..c3acd9a5d 100644 --- a/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java +++ b/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/TestcaseRunner.java @@ -192,7 +192,7 @@ private static void renderPDF(String html, OutputStream outputStream) throws Exc } } - private static DefaultObjectDrawerFactory buildObjectDrawerFactory() { + static DefaultObjectDrawerFactory buildObjectDrawerFactory() { DefaultObjectDrawerFactory objectDrawerFactory = new StandardObjectDrawerFactory(); objectDrawerFactory.registerDrawer("custom/binary-tree", new SampleObjectDrawerBinaryTree()); return objectDrawerFactory; diff --git a/openhtmltopdf-examples/src/main/resources/testcases/FSPageBreakMinHeightSample.html b/openhtmltopdf-examples/src/main/resources/testcases/FSPageBreakMinHeightSample.html index a34e80b7d..40f05b391 100644 --- a/openhtmltopdf-examples/src/main/resources/testcases/FSPageBreakMinHeightSample.html +++ b/openhtmltopdf-examples/src/main/resources/testcases/FSPageBreakMinHeightSample.html @@ -1,5 +1,13 @@ + + + + + + + +