Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Pdf is rotated

Help
AvrDragon
2011-11-02
2013-05-28
  • AvrDragon
    AvrDragon
    2011-11-02

    Pdf file is rendered rotated. This happens in example app to.
    But in acroread it looks correct.
    Is the problem with version 1.6?
    PDF file: http://daris.kbv.de/daris/doccontent.dll?LibraryName=EXTDARIS^DMSSLAVE&SystemType=2&LogonId=55a113a7a5a20854715ef06e439d1e7e&DocId=003764052&Page=1

     

  • Anonymous
    2011-11-03

    Your link is broken.

    Anyway, a PDF page has a rotation property, this is most probably the case here. The example does not take into account for this. A more complete rendering sequence would look like:

                    transformPage.setToIdentity();
            Rectangle2D normalizedPagerect = getPage().getCropBox()
                    .toNormalizedRectangle();
            PDFGeometryTools.adjustTransform(transformPage,
                    PDFGeometryTools.normalizeRotate(getPage().getRotate()),
                    normalizedPagerect);
            //
            double[] extent = new double[2];
            extent[0] = normalizedPagerect.getWidth();
            extent[1] = normalizedPagerect.getHeight();
            transformPage.deltaTransform(extent, 0, extent, 0, 1);
            double pageWidth = Math.abs(extent[0]);
            double pageHeight = Math.abs(extent[1]);
            //
            int imgWidth = Math.abs((int) (pageWidth * scale));
            int imgHeight = Math.abs((int) (pageHeight * scale));
            double scaleX = scale;
            double scaleY = -scale;
            BufferedImage image = new BufferedImage(imgWidth, imgHeight,
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = (Graphics2D) image.getGraphics();
            IGraphicsContext g = new CwtAwtGraphicsContext(g2);
            // init user space
            transform.setToIdentity();
            // apply conversion from screen to pdf page
            transform.scale(scaleX, scaleY);
            transform.translate(0, -pageHeight);
            // apply pdf internal page transformation
            transform.concatenate(transformPage);
            try {
                g.transform(transform);
                renderPage(g);
                writePage(image);
            } finally {
                g.dispose();
            }
    

    (not tested)

     
  • AvrDragon
    AvrDragon
    2011-11-03

    Thank you, it's the case.

    P.S. For the sake of completeness, link is http://www.kbv.de/service/6253.html (Muster 10)