You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2015/01/28 20:54:37 UTC
[jira] [Commented] (PDFBOX-2634) Multiple text operations on
multiple pages cause NPE in TTFSubsetter
[ https://issues.apache.org/jira/browse/PDFBOX-2634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295722#comment-14295722 ]
John Hewson commented on PDFBOX-2634:
-------------------------------------
You've uncovered quite a big flaw - the subsetting code works on a per-page basis, which of course, breaks when you have more than one page. While named resources in PDF are per-page, the font objects that these resources point to are per-document. Whoops.
The solutions is going to be rather involved - subsetting will need to be deferred until the document is about to be saved, and PDDocument will need to keep track of all fonts which are to be subset.
> Multiple text operations on multiple pages cause NPE in TTFSubsetter
> --------------------------------------------------------------------
>
> Key: PDFBOX-2634
> URL: https://issues.apache.org/jira/browse/PDFBOX-2634
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 2.0.0
> Reporter: Alex Nevidomsky
>
> Problem seems to be of the same nature as in PDFBOX-2605, in a slightly different scenario.
> {code:title=NullPTest.java}
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDPage;
> import org.apache.pdfbox.pdmodel.common.PDRectangle;
> import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
> import org.apache.pdfbox.pdmodel.font.PDFont;
> import org.apache.pdfbox.pdmodel.font.PDType0Font;
> import org.junit.Test;
> public class NullPTest {
> @Test
> public void testMultipageUnicodePDF() throws Exception {
> PDDocument document = new PDDocument();
> PDFont titleFont = PDType0Font.load(document, this.getClass().getResourceAsStream("/Arial Unicode.ttf"));
> PDPage page = new PDPage(PDRectangle.A4);
> document.addPage(page);
> PDPageContentStream contentStream = new PDPageContentStream(document, page);
> contentStream.beginText();
> contentStream.setFont(titleFont, 12);
> contentStream.newLineAtOffset(0, 100);
> contentStream.showText("Pěkný žluťoučký kůň úpěl ďábelské ódy");
> contentStream.endText();
> contentStream.close();
>
> page = new PDPage(PDRectangle.A4);
> document.addPage(page);
> contentStream = new PDPageContentStream(document, page);
> contentStream.beginText();
> contentStream.setFont(titleFont, 12);
> contentStream.newLineAtOffset(0, 200);
> contentStream.showText("Pěkný žluťoučký kůň úpěl ďábelské ódy");
> contentStream.endText();
> contentStream.close();
> document.close();
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org