Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52FDC18A4F for ; Thu, 5 Nov 2015 16:22:51 +0000 (UTC) Received: (qmail 67605 invoked by uid 500); 5 Nov 2015 16:22:50 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 67588 invoked by uid 500); 5 Nov 2015 16:22:50 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Delivered-To: moderator for users@pdfbox.apache.org Received: (qmail 72398 invoked by uid 99); 5 Nov 2015 15:32:09 -0000 X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.99 X-Spam-Level: *** X-Spam-Status: No, score=3.99 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_OBFU_PDF_ATTACH=0.01] autolearn=disabled To: users@pdfbox.apache.org MIME-Version: 1.0 Subject: PDF to BMP problem X-KeepSent: E362BA82:ABE25BDA-C1257EF4:00554A1B; type=4; name=$KeepSent X-Mailer: IBM Notes Release 9.0.1 October 14, 2013 Message-ID: From: Jarek Stempien Date: Thu, 5 Nov 2015 16:31:47 +0100 X-MIMETrack: Serialize by Router on mama/notes(Release 9.0.1FP2|August 03, 2014) at 11/05/2015 16:31:58 Content-Type: multipart/mixed; boundary="=_mixed 00554F01C1257EF4_=" --=_mixed 00554F01C1257EF4_= Content-Type: multipart/alternative; boundary="=_alternative 00554F01C1257EF4_=" --=_alternative 00554F01C1257EF4_= Content-Type: text/plain; charset="US-ASCII" Hi, I'm trying to convert PDF to BMP and I've problem with quality. Can you help me? Is there something wrong with code? PDDocument document = null; try { document = PDDocument.load( new java.io.File(pdfFile) ); } catch (Exception e) { e.printStackTrace(); return false; } writeImage(document, "bmp", 1, Integer.MAX_VALU, ImageType.RGB, 96, outputFiles, 800); public boolean writeImage(PDDocument document, String imageFormat, int startPage, int endPage, ImageType imageType, int dpi, List outputFiles, int maxWidth) throws IOException { boolean bSuccess = true; endPage = Math.min(endPage, document.getNumberOfPages()); PDFRenderer renderer = new PDFRenderer(document); for (int i = startPage - 1, j=0; i < endPage; i++,j++) { PDPage page = document.getPage(i); PDRectangle cropbBox = page.getCropBox(); float widthPt = cropbBox.getWidth(); float scale = 1f; if(maxWidth != -1) { scale = (float)maxWidth/widthPt; } BufferedImage image = renderer.renderImage(i, scale, imageType); if(j + 1 > outputFiles.size()) { outputFiles.add(new ByteArrayOutputStream()); } bSuccess &= ImageIOUtil.writeImage(image, imageFormat, outputFiles.get(j), dpi); } return bSuccess; } I see also that PDRectangle cropbBox is very small. Regards Jarek --=_alternative 00554F01C1257EF4_= Content-Type: text/html; charset="US-ASCII" Hi,

I'm trying to convert PDF to BMP and I've problem with quality. Can you help me? Is there something wrong with code?



PDDocument document = null;
        try
        {
            document = PDDocument.load( new java.io.File(pdfFile) );
        }
        catch (Exception e)
        {
                e.printStackTrace();
                return false;
        }
writeImage(document, "bmp", 1, Integer.MAX_VALU, ImageType.RGB, 96, outputFiles, 800);

public boolean writeImage(PDDocument document, String imageFormat, int startPage, int endPage,
                    ImageType imageType, int dpi, List<OutputStream> outputFiles, int maxWidth) throws IOException
    {
        boolean bSuccess = true;
        endPage = Math.min(endPage, document.getNumberOfPages());
       
        PDFRenderer renderer = new PDFRenderer(document);
       
        for (int i = startPage - 1, j=0; i < endPage; i++,j++)
        {
                PDPage page = document.getPage(i);
               
                PDRectangle cropbBox = page.getCropBox();
                float widthPt = cropbBox.getWidth();
                float scale = 1f;
                if(maxWidth != -1)
                {
                        scale = (float)maxWidth/widthPt;
                }
                BufferedImage image = renderer.renderImage(i, scale, imageType);
               
                if(j + 1 > outputFiles.size())
                {
                        outputFiles.add(new ByteArrayOutputStream());
                }
            bSuccess &= ImageIOUtil.writeImage(image, imageFormat, outputFiles.get(j), dpi);
        }
        return bSuccess;
    }

I see also that PDRectangle cropbBox is very small.

Regards
Jarek --=_alternative 00554F01C1257EF4_=-- --=_mixed 00554F01C1257EF4_= Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org --=_mixed 00554F01C1257EF4_=--