Printing of PDF with embedded OTF/TTF fonts is not working
----------------------------------------------------------

                 Key: PDFBOX-965
                 URL: https://issues.apache.org/jira/browse/PDFBOX-965
             Project: PDFBox
          Issue Type: Bug
          Components: PDFReader
    Affects Versions: 1.5.0
         Environment: OSX 10.6.6, JDK 1.6_022
            Reporter: Clemens Lanthaler


I want to print a PDF created with iText 2.1.7 which includes a OTF Font. I 
have also converted the fonts to TTF fonts and recreated the pdf but pdfbox is 
not able to print the pdf file. The result is that the printer outputs 10 empty 
pages.

My code to print the pdf file:
private void printPDF(byte[] barrayBs) throws IOException, 
CryptographyException, InvalidPasswordException, PrinterException {
       String password = "";
       String printerName = null;
       PDDocument document = null;
       try {            
           document = PDDocument.load(new ByteArrayInputStream(barrayBs));
           //document = PDDocument.load("/Users/selfemp/Desktop/pr2.pdf");
           //PDFont font = PDTrueTypeFont.loadTTF( document, new 
File("/Users/selfemp/Desktop/fonts/TeXGyreAdventor-Regular.ttf"));
           //PDFont font2 = PDTrueTypeFont.loadTTF( document, new 
File("/Users/selfemp/Desktop/fonts/TeXGyreAdventor-Bold.ttf"));
           if (document.isEncrypted()) {
               document.decrypt(password);
           }            
           PrinterJob printJob = PrinterJob.getPrinterJob();
           printJob.setJobName("WIST-Report");
           if (printerName != null) {
               PrintService[] printService = PrinterJob.lookupPrintServices();
               boolean printerFound = false;
               for (int i = 0; !printerFound && i < printService.length; i++) {
                   if (printService[i].getName().indexOf(printerName) != -1) {
                       printJob.setPrintService(printService[i]);
                       printerFound = true;
                   }
               }
           }
           document.silentPrint(printJob);
       } finally {
           if (document != null) {
               document.close();
           }
       }
   }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to