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: Poor performance creating PDF page from buffered image.
Date Mon, 11 Jun 2018 16:54:57 GMT
There's nothing we can do... I suggest you run the profiler to see where 
the time is lost. Likely not in PDFBox.

Also make sure that your input is a file and not a stream. I remember we 
once had a problem, see
https://issues.apache.org/jira/browse/PDFBOX-4121

You could also try using the twelvemonkeys library.

Tilman

Am 11.06.2018 um 15:09 schrieb Kirk, Kenneth:
> I believe it was faster in the case of good images produced by modern software.
> In the case of the images that I am processing, that were created 20 years ago, where
the IFD has bad tags that don't
> reference the next IFD properly, I need to grab the pages that are accessible and flag
the
> resulting PDF for review.
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Saturday, June 09, 2018 1:37 AM
> To: users@pdfbox.apache.org
> Subject: Re: Poor performance creating PDF page from buffered image.
>
> So was it faster when you used CCITTFactory.createFromFile?
>
> Tilman
>
>
> Am 08.06.2018 um 20:46 schrieb Kirk, Kenneth:
>> I started out using CCITTFactory.createFromFile but some of the images were corrupt
but salvageable.
>> I loop through each page until I get an exception. If the first page is readable
the user has enough information
>> To continue with the process.
>>
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Friday, June 08, 2018 1:39 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: Poor performance creating PDF page from buffered image.
>>
>> You're creating the image the hard way... try CCITTFactory.createFromFile
>>
>> Tilman
>>
>> Am 08.06.2018 um 20:34 schrieb Kirk, Kenneth:
>>> When I run the following code:
>>>
>>> IIOMetadata tiffMetadata = reader.getImageMetadata(p);
>>> BufferedImage image = reader.read(p);
>>> IIOMetadataNode root = (IIOMetadataNode) tiffMetadata.getAsTree("javax_imageio_1.0");
>>> IIOMetadataNode dimension = (IIOMetadataNode) root.getElementsByTagName("Dimension").item(0);
>>> float horizontalPixelSizeMM = getPixelSizeMM(dimension, "HorizontalPixelSize");
>>> float verticalPixelSizeMM = getPixelSizeMM(dimension, "VerticalPixelSize");
>>> float xRes = 25.4f / horizontalPixelSizeMM;
>>> float yRes = 25.4f / verticalPixelSizeMM;
>>> PDImageXObject ximage = CCITTFactory.createFromImage(pdf, image);
>>> float wScale = (ximage.getWidth() / xRes) * 72f;
>>> float hScale = (ximage.getHeight() / yRes) * 72f;
>>> PDPage page = new PDPage(new PDRectangle((float)wScale, (float)hScale));
>>> PDPageContentStream stream = new PDPageContentStream(pdf, page);
>>> Dimension scaledDim = getScaledDimension( new Dimension(ximage.getWidth(), ximage.getHeight()),
>>>                                              new Dimension((int) page.getMediaBox().getWidth(),
>>>                                              (int) page.getMediaBox().getHeight()));
>>> stream.drawImage(ximage, 0, 0, wScale, hScale);
>>> stream.close();
>>> pdf.addPage( page );
>>>
>>> the PDImageXObject take 30 to 45 seconds to generate an object from 8.5x11 tiff
image that I use ImageIO to produce
>>> a bufferedimage.  I cannot share the image due to regulations but there is nothing
fancy about them.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ************************************************
>>> Disclaimer - This email and any files transmitted with it are confidential and
contain privileged or copyright information. You must not present this message to another
party without gaining permission from the sender. If you are not the intended recipient you
must not copy, distribute or use this email or the information contained in it for any purpose
other than to notify the Office of the Illinois Secretary of State.
>>>
>>> If you have received this message in error, please notify the sender immediately,
and delete this email from your system. Any views expressed in this message are those of the
individual sender, except where the sender specifically states them to be the views of the
Office of the Illinois Secretary of State.
>>> ************************************************
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ************************************************
>> Disclaimer - This email and any files transmitted with it are confidential and contain
privileged or copyright information. You must not present this message to another party without
gaining permission from the sender. If you are not the intended recipient you must not copy,
distribute or use this email or the information contained in it for any purpose other than
to notify the Office of the Illinois Secretary of State.
>>
>> If you have received this message in error, please notify the sender immediately,
and delete this email from your system. Any views expressed in this message are those of the
individual sender, except where the sender specifically states them to be the views of the
Office of the Illinois Secretary of State.
>> ************************************************
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain
privileged or copyright information. You must not present this message to another party without
gaining permission from the sender. If you are not the intended recipient you must not copy,
distribute or use this email or the information contained in it for any purpose other than
to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and
delete this email from your system. Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be the views of the Office of
the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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