-
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 #19 from rototor/Table-Pagebreak-Repater-Bug
Table page break bug and PDFBOX character bug test cases. Thanks @rototor
- Loading branch information
Showing
2 changed files
with
495 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/RepeatedTableSample.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,33 @@ | ||
package com.openhtmltopdf.testcases; | ||
|
||
import com.openhtmltopdf.bidi.support.ICUBidiReorderer; | ||
import com.openhtmltopdf.bidi.support.ICUBidiSplitter; | ||
import com.openhtmltopdf.pdfboxout.PdfBoxRenderer; | ||
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder; | ||
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder.TextDirection; | ||
import org.apache.pdfbox.io.IOUtils; | ||
import org.apache.pdfbox.util.Charsets; | ||
|
||
import java.io.FileOutputStream; | ||
|
||
public class RepeatedTableSample { | ||
public static void main(String[] args) throws Exception { | ||
byte[] htmlBytes = IOUtils.toByteArray(RepeatedTableSample.class | ||
.getResourceAsStream("/testcases/RepeatedTableSample.html")); | ||
String html = new String(htmlBytes, Charsets.UTF_8); | ||
FileOutputStream outputStream = new FileOutputStream("RepeatedTableSample.pdf"); | ||
PdfRendererBuilder builder = new PdfRendererBuilder(); | ||
builder.useBidiSplitter(new ICUBidiSplitter.ICUBidiSplitterFactory()); | ||
builder.useBidiReorderer(new ICUBidiReorderer()); | ||
builder.defaultTextDirection(TextDirection.LTR); | ||
builder.withHtmlContent(html, ""); | ||
builder.toStream(outputStream); | ||
PdfBoxRenderer pdfBoxRenderer = builder.buildPdfRenderer(); | ||
// Add Noto Sans Font | ||
// pdfBoxRenderer.getFontResolver().addFont(tempFile.getPath(), null); | ||
pdfBoxRenderer.layout(); | ||
pdfBoxRenderer.createPDF(); | ||
outputStream.close(); | ||
|
||
} | ||
} |
Oops, something went wrong.