Skip to content

Commit

Permalink
Merge pull request #19 from rototor/Table-Pagebreak-Repater-Bug
Browse files Browse the repository at this point in the history
Table page break bug and PDFBOX character bug test cases. Thanks @rototor
  • Loading branch information
danfickle committed Apr 14, 2016
2 parents 89ff4ff + a53bf2e commit ffe3ee7
Show file tree
Hide file tree
Showing 2 changed files with 495 additions and 0 deletions.
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();

}
}
Loading

0 comments on commit ffe3ee7

Please sign in to comment.