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 Fri, 08 Jun 2018 18:38:32 GMT
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


Mime
View raw message