I have solved my issue by switching to com.itextpdf.text.pdf.PdfCopy.
I no longer need a separate rotate process, but if I did
com.itextpdf.text.pdf.PdfDictionary and
com.itextpdf.text.pdf.PdfStamper  will rotate.

On Thu, Jan 19, 2012 at 12:34 PM, Stephen More <[email protected]> wrote:
> I have tried multiple ways to rotate the content of a page using
> 5.1.3, but nothing seems to be working for me. I either get a blank
> page, or no difference.
>
>
> current working code:
>                com.itextpdf.text.pdf.PdfDictionary pageDict =
> reader.getPageN( pageNum );
>                com.itextpdf.text.pdf.PdfNumber pageRot =
> pageDict.getAsNumber( com.itextpdf.text.pdf.PdfName.ROTATE );
>                log.trace( "Rotation: " + pageRot );
>
>                currentPageNumber++;
>                if( getSizeWithRotation )
>                {
>                        document.setPageSize(
> reader.getPageSizeWithRotation( pageNum ) );
>                }
>                document.newPage();
>                com.itextpdf.text.pdf.PdfImportedPage page =
> writer.getImportedPage( reader, pageNum );
>                cb.addTemplate( page, 0, 0 );
>
>                if( footer )
>                {
>                        cb.beginText();
>                        cb.setFontAndSize( bf, 9 );
>                        cb.showTextAligned(
> com.itextpdf.text.pdf.PdfContentByte.ALIGN_CENTER, "Page: " +
> currentPageNumber, 520, 5, 0);
>                        cb.endText();
>                }
>
>
> Have tried before document.setPageSize:
>                        log.debug( "Adding 90 to rotate" );
>                        int currRot = pageRot.intValue();
>                        currRot += 90;
>                        currRot %= 360;
>                        com.itextpdf.text.pdf.PdfNumber newRot = new
> com.itextpdf.text.pdf.PdfNumber( currRot );
>                        pageDict.put(
> com.itextpdf.text.pdf.PdfName.ROTATE, newRot );
>
> Also tried:
>                 java.awt.geom.AffineTransform affineTransform = new
> java.awt.geom.AffineTransform();
>                 affineTransform.rotate( java.lang.Math.toRadians( 90 ) );
>                 cb.addTemplate( page, affineTransform );
>
> Also tried:
>                float rotate = 90;
>                float x = 0;
>                float y = 0;
>                float angle  = (float)(-rotate * (Math.PI / 180));
>                float xScale = (float)(Math.cos(angle));
>                float yScale = (float)(Math.cos(angle));
>                float xRote  = (float)(-Math.sin(angle));
>                float yRote  = (float)(Math.sin(angle));
>
>                cb.addTemplate( page, xScale, xRote, yRote, yScale, x, y );
>
> Can anyone point out what I am doing wrong ?
>
> -Thanks

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to