pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: PostScript files out of PDFBox seem to be bloated
Date Fri, 26 Aug 2016 19:33:00 GMT
Asked and answered in
https://stackoverflow.com/questions/39109841/printing-to-postscript-with-pdfbox-produces-a-massive-file-why

Additionally, re the comment of Ken Sharp (who is a Ghostcript guy and 
thus has my maximum respect): PDFBox is not a converter, it renders 
regardless of the target format.

In theory, it might be possible to make a converter, by replacing all 
graphics method calls with postscript commands.

Tilman

Am 26.08.2016 um 21:25 schrieb Clark, Raymond C:
> 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.
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message