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 20:22:47 GMT
Am 26.08.2016 um 22:18 schrieb Clark, Raymond C:
> Thank you,
>
> I guess I'm off to look for a tool to create PostScript files out of Java.  Thank you
all for your help with my question :)


I think Apache FOP can also generate PS files.

Tilman

>
> Thank you,
> Ray
>
> -----Original Message-----
> From: John Hewson [mailto:john@jahewson.com]
> Sent: Friday, August 26, 2016 3:12 PM
> To: users@pdfbox.apache.org
> Subject: Re: PostScript files out of PDFBox seem to be bloated
>
>
>> On 26 Aug 2016, at 13:09, Tilman Hausherr <THausherr@t-online.de> wrote:
>>
>> Am 26.08.2016 um 21:57 schrieb Clark, Raymond C:
>>> Hi Tilman,
>>>
>>> Thank you for the reply.  I don't see how that post was the same as mine and
is answered.  Forgive me.
>> I tought you were the same person, some of the code looked identical. If not - sorry!
Some users ask the same question on SO and here.
>>
>>> That question was "What do I need to change to create a reasonably sized PostScript
file?"  The only answer that I see is that PostScript files are big by nature.
>> Sadly, yes.
>>
>>> My question was, "Is there a way in PDFBox to have it put the text directly into
the PostScript file instead of passing it on as part of an image?"  Seems like a different
question to me.  Sorry if I am mistaken.
>> PDFBox doesn't create PS files itself. If ever, it's the PS printer driver who does.
Btw PDFBox doesn't create images from text, it creates vector graphics (which gets huge).
> Just to add to this, the Java printing API can put text directly into the print output,
but only for AWT fonts. We don't use AWT fonts because of buggy rendering. Instead, we render
fonts to vector paths ourselves. It is these paths which are making the PostScript output
so large.
>
> It's certainly possible to build a PostScript converter on top of PDFBox using our APIs,
but you're not going get good results with Java's built-in AWT PostScript driver.
>
> - John
>
>> Tilman
>>
>>
>>> Ray
>>>
>>> -----Original Message-----
>>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>>> Sent: Friday, August 26, 2016 2:33 PM
>>> To: users@pdfbox.apache.org
>>> Subject: Re: PostScript files out of PDFBox seem to be bloated
>>>
>>> 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
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org <mailto:users-unsubscribe@pdfbox.apache.org>
>> For additional commands, e-mail: users-help@pdfbox.apache.org <mailto:users-help@pdfbox.apache.org>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


Mime
View raw message