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
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to