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..c3acd9a5d 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");
@@ -190,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 @@
+
+
+
+
+
+
+
+
+
+
+
+ asdasdasd
+
+
+
diff --git a/openhtmltopdf-examples/src/main/resources/testcases/svg-sizes.html b/openhtmltopdf-examples/src/main/resources/testcases/svg-sizes.html
index c1818c65e..3a2e4ec6e 100644
--- a/openhtmltopdf-examples/src/main/resources/testcases/svg-sizes.html
+++ b/openhtmltopdf-examples/src/main/resources/testcases/svg-sizes.html
@@ -1,15 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
- Text
+ Text
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec venenatis velit enim, a placerat lectus viverra non.
Proin varius porta ligula, in fringilla erat suscipit a.
- SVG
+ SVG
- width: percentage, max-width: none, calc-width: 25%
+ width: percentage, max-width: none, calc-width: 25%
@@ -17,7 +30,7 @@ width: percentage, max-width: none, calc-width: 25%
stroke="blue" fill="yellow" stroke-width="2" />
- width: percentage, max-width: absolute, calc-width: 8cm
+ width: percentage, max-width: absolute, calc-width: 8cm
@@ -25,7 +38,7 @@ width: percentage, max-width: absolute, calc-width: 8cm
stroke="blue" fill="yellow" stroke-width="2" />
- width: absolute, max-width: percentage, calc-width: 10%
+ width: absolute, max-width: percentage, calc-width: 10%
@@ -34,7 +47,7 @@ width: absolute, max-width: percentage, calc-width: 10%
- height: absolute, max-height: none, calc-height: 4cm
+ height: absolute, max-height: none, calc-height: 4cm
@@ -42,7 +55,7 @@ height: absolute, max-height: none, calc-height: 4cm
stroke="blue" fill="yellow" stroke-width="2" />
- height: absolute, max-height: percentage, calc-height: 2.5cm (50% of containing block)
+ height: absolute, max-height: percentage, calc-height: 2.5cm (50% of containing block)
height: absolute, max-height: percentage, calc-height: 2.5cm (50% of contain
- height: absolute, max-height: absolute, calc-height: 4cm
+ height: absolute, max-height: absolute, calc-height: 4cm
diff --git a/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/testcases/ConcateOutputTest.java b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/testcases/ConcateOutputTest.java
new file mode 100644
index 000000000..fd1c3efe4
--- /dev/null
+++ b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/testcases/ConcateOutputTest.java
@@ -0,0 +1,59 @@
+package com.openhtmltopdf.testcases;
+
+import static com.openhtmltopdf.testcases.TestcaseRunner.buildObjectDrawerFactory;
+
+import java.io.File;
+
+import org.apache.pdfbox.io.IOUtils;
+import org.apache.pdfbox.io.MemoryUsageSetting;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.util.Charsets;
+import org.junit.Test;
+
+import com.openhtmltopdf.bidi.support.ICUBidiReorderer;
+import com.openhtmltopdf.bidi.support.ICUBidiSplitter;
+import com.openhtmltopdf.latexsupport.LaTeXDOMMutator;
+import com.openhtmltopdf.mathmlsupport.MathMLDrawer;
+import com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder;
+import com.openhtmltopdf.pdfboxout.PdfBoxRenderer;
+import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
+import com.openhtmltopdf.svgsupport.BatikSVGDrawer;
+
+public class ConcateOutputTest {
+
+ @Test
+ public void testConcateOutput() throws Exception {
+ File targetFile = new File("target/test/concatoutput/concated.pdf");
+ targetFile.getParentFile().mkdirs();
+ PDDocument doc = new PDDocument(MemoryUsageSetting.setupMixed(1000000));
+
+ for (String testCaseFile : new String[] { "color", "background-color",
+ "FSPageBreakMinHeightSample", "math-ml", "multi-column-layout", "simplerotate",
+ "svg-inline", "svg-sizes", "transform", "RepeatedTableSample",
+ "RepeatedTableTransformSample" }) {
+ renderPDF(testCaseFile, doc);
+ }
+
+ doc.save(targetFile);
+ doc.close();
+
+ }
+
+ private static void renderPDF(String testCaseFile, PDDocument document) throws Exception {
+ byte[] htmlBytes = IOUtils
+ .toByteArray(TestcaseRunner.class.getResourceAsStream("/testcases/" + testCaseFile + ".html"));
+ String html = new String(htmlBytes, Charsets.UTF_8);
+ PdfRendererBuilder builder = new PdfRendererBuilder();
+ builder.useUnicodeBidiSplitter(new ICUBidiSplitter.ICUBidiSplitterFactory());
+ builder.useUnicodeBidiReorderer(new ICUBidiReorderer());
+ builder.defaultTextDirection(BaseRendererBuilder.TextDirection.LTR);
+ builder.useSVGDrawer(new BatikSVGDrawer());
+ builder.useMathMLDrawer(new MathMLDrawer());
+ builder.addDOMMutator(LaTeXDOMMutator.INSTANCE);
+ builder.useObjectDrawerFactory(buildObjectDrawerFactory());
+ builder.withHtmlContent(html, TestcaseRunner.class.getResource("/testcases/").toString());
+ builder.usePDDocument(document);
+ PdfBoxRenderer pdfBoxRenderer = builder.buildPdfRenderer();
+ pdfBoxRenderer.createPDFWithoutClosing();
+ }
+}
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);
}
diff --git a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java
index 6a72ec6ec..23e5b7cca 100644
--- a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java
+++ b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxRenderer.java
@@ -129,6 +129,7 @@ public class PdfBoxRenderer implements Closeable {
_useFastMode = state._useFastRenderer;
_outputDevice = new PdfBoxOutputDevice(DEFAULT_DOTS_PER_POINT, _testMode);
_outputDevice.setWriter(_pdfDoc);
+ _outputDevice.setStartPageNo(_pdfDoc.getNumberOfPages());
PdfBoxUserAgent userAgent = new PdfBoxUserAgent(_outputDevice);