[ 
https://issues.apache.org/jira/browse/PDFBOX-5621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17732684#comment-17732684
 ] 

Tilman Hausherr edited comment on PDFBOX-5621 at 6/14/23 6:40 PM:
------------------------------------------------------------------

The cause is {{processSoftMask}}, it doesn't save and restore textMatrix while 
the softmask is processed. The softmask has text and when encountering the "ET" 
operator, the textMatrix is reset to null. In {{processType3Stream()}} we avoid 
this problem by saving the textMatrix and another variable. It's really 
surprising that this hasn't hit us all these years.


was (Author: tilman):
The cause is {{processSoftMask}}, it doesn't save textMatrix. The softmask has 
text and when encountering ET, the textMatrix is reset to null. In 
{{processType3Stream()}} we're taking care of this. It's really surprising that 
this hasn't hit us all these years.

> NullPointerException in PDFStreamEngine.showText
> ------------------------------------------------
>
>                 Key: PDFBOX-5621
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5621
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.28
>         Environment: Windows 10/11, openjdk 13.0.1
>            Reporter: Robert Verheus
>            Priority: Major
>             Fix For: 2.0.29, 3.0.0 PDFBox
>
>         Attachments: A3 poster.pdf
>
>
> I'm trying to print a pdf with PDFBox (version 2.0.28) which contains one 
> page.
> The pdf looks ok when I open it in Acrobat reader.
> The code to print is the following:
> {code:java}
> PDDocument doc = PDDocument.load(pdffile);
> m_printjob = PrinterJob.getPrinterJob();
> m_printjob.setPrintService(service);
> m_printjob.setJobName(pdffile.getName());
> m_printjob.setCopies(1);
> Paper paper = m_printjob.defaultPage().getPaper(); //default page format of 
> the printer
> paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight()); // no 
> margins
> PageFormat pageFormat = printjob.getPageFormat(null);
> pageFormat.setPaper(paper);
> m_printjob.setPageable(...); //slightly altered PDFPageable to better suit 
> our scaling/orientation needs.
> PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
> attr.add(Sides.ONE_SIDED);
> m_printjob.print(attr); {code}
> Result is:
> {noformat}
> 13-06-2023 15:37:28,244 ERROR  - java.lang.NullPointerException
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:793)
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:681)
>     at 
> org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:53)
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:966)
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:541)
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:516)
>     at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155)
>     at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:284)
>     at 
> org.apache.pdfbox.rendering.PDFRenderer.renderPageToGraphics(PDFRenderer.java:465)
>     at org.apache.pdfbox.printing.PDFPrintable.print(PDFPrintable.java:264)
>     at 
> java.desktop/sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2275)
>     at 
> java.desktop/sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1654)
>     at 
> com.xafax.easyprint.was.print.UploadJobServlet$3.run(UploadJobServlet.java:1856)
>     at java.base/java.lang.Thread.run(Thread.java:830){noformat}
> I have attached the pdf which causes this NullPointerException.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to