-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from rototor/fix_and_sample_multihtmldoc_pdf
- Loading branch information
Showing
7 changed files
with
108 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
openhtmltopdf-examples/src/main/resources/testcases/simplerotate.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<style>@page {size: 520px 820px;margin: 0px;padding: 0px;}body {margin: 0;}</style> | ||
</head> | ||
<body> | ||
<div style="left:0px;top:0px;width:50px;transform: rotate(50deg);"> | ||
asdasdasd | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
openhtmltopdf-examples/src/test/java/com/openhtmltopdf/testcases/ConcateOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters