pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Lehmkühler" <andr...@lehmi.de>
Subject Re: can not print page in landscape orientation
Date Thu, 15 Mar 2012 20:19:34 GMT
Hi,


Alexey Monakhov <noittom@gmail.com> hat am 13. März 2012 um 20:50 geschrieben:

> Hello,
> I have problem -  I want to print page in landscape mode,
> the page is this one
>  http://www.tnt3s.ch/s3/data/test/label-landscape.pdf
>
> I rotate it and print
>  PDDocument outputPDFFile = new PDDocument(); ;
>             for( PDPage page: l ){
>             page.setRotation(90);
>                 outputPDFFile.importPage( page );
>             }
>
>            outputPDFFile.silentPrint(printJob);
>
> but got this error
>
> ARNING: java.lang.NullPointerException
> java.lang.NullPointerException
>  at
> org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getawtFont(PDTrueTypeFont.java:425)
> at
> org.apache.pdfbox.pdmodel.font.PDSimpleFont.drawString(PDSimpleFont.java:101)
>  at
> org.apache.pdfbox.pdfviewer.PageDrawer.processTextPosition(PageDrawer.java:194)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:494)
>  at org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:551)
>  at
> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:274)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:251)
>  at
> org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:225)
> at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:107)
>  at org.apache.pdfbox.pdmodel.PDPage.print(PDPage.java:824)
> at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2008)
>  at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1457)
> at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1273)
>  at org.apache.pdfbox.pdmodel.PDDocument.print(PDDocument.java:1273)
> at org.apache.pdfbox.pdmodel.PDDocument.silentPrint(PDDocument.java:1264)
>  at PdfPrinter.run(PdfPrinter.java:201)
> at PrintDocument.main(PrintDocument.java:43)
>
> WHY?
> and the thing is that if I do not rotate it I can print without any problem
> ( but in portrait orientation only.
>
> any ideas?


You should try something like this to load the pdf:

PDDocument document = PDDocument.load( "document.pdf" );

You must not set the rotation. Those information should be already part of the
pdf.



> > Alexey

BR
Andreas Lehmkühler
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message