pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clark, Raymond C" <Raymond.C.Cl...@ehi.com>
Subject PostScript files out of PDFBox seem to be bloated
Date Fri, 26 Aug 2016 19:25:32 GMT
Hi,

I am using PDFBox to create PDFs and that is working great.  I need to take those PDF files
and produce PostScript files from them.  I can do that but the file is bloated.  I am creating
the content streams with compress = true.  It seems to be that the following code is producing
the PS file as an image of the page instead of extracting the text and images and coding that
as a PostScript file.  Is it possible to use PDFBox to create a PostScript file with the text
in it instead of an image of the page?

This is a snippet of the code I am using to create the PostScript file:

             pdfGenerator.finishFileCreation();
             DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
             StreamPrintServiceFactory[] factories =
                           StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,
                                        DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
             if (factories.length == 0) {
                    throw new PrinterException("No PostScript factories available");
             }
             PDDocument document = pdfGenerator.getDocument();

             PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
             aset.add(MediaSizeName.NA_LETTER);
//         aset.add(Sides.DUPLEX);

             DocAttributeSet daset = new HashDocAttributeSet();
//           daset.add(Compression.GZIP);

             FileOutputStream fos = new FileOutputStream(filePathAndName);
             Map<Integer, String> pageLayoutMap = pdfGenerator.getPageLayoutMap();
             for (int i = 1; i <= document.getNumberOfPages(); i++) {
                    aset.add(new PageRanges(i, i));
                    if (pageLayoutMap.get(i).equals(PDFGenerator.ORIENTATION_LANDSCAPE)) {
                           aset.add(OrientationRequested.LANDSCAPE);
                    } else {
                           aset.add(OrientationRequested.PORTRAIT);
                    }
                    factories[0].getPrintService(fos).createPrintJob().print(
                                 new SimpleDoc(new PDFPrintable(document, Scaling.ACTUAL_SIZE,
false), flavor, daset), aset);
             }
             fos.close();
             document.close();

Thank you,
Ray

________________________________

CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely
for the use of the individual or entity to whom they are addressed and may contain confidential
and privileged information protected by law. If you received this e-mail in error, any review,
use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please
notify the sender immediately by return e-mail and delete all copies from your system.



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message