It's fairly easy to "cheat" with AffineTransform.

AffineTransform trans = AffineTransform.getRotateInstance( 
// I think the 360 - rot is right... not entirely sure
  Math.toRadians(360 - pagesRotation)
);
double matrix[] = double[6];
trans.getMatrix(matrix);

content.concatCTM( (float)matrix[0], (float)matrix[1], (float)matrix[2],
(float)matrix[3], (float)matrix[4], (float)matrix[5] );

I think there's now a PdfContentByte.concatCTM override that takes an
AffineTransform directly, but that might only be in the post-5.x
world... I don't recall when I added it.

--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
> -----Original Message-----
> From: RivasAviles, Miguel [mailto:miguel.rivasavi...@fwisd.org]
> Sent: Thursday, May 20, 2010 4:25 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Document rotates while merging
> 
> Thank you Eric for pointing me on the right direction.
> 
> I put couple of hours with the approach you told me and was able to
rotate
> the page (270) but now I have it upside down.
> 
> But looking for more answers on the web seems to me like I opened a
> pandora's box... people getting angry when talking about that
matrix...
> I'm  even scare to ask about it :)
> 
> Any ways thank you for your answer.  I think I'll have to go back to
my
> old math books... man more that 15 years without touching that!
> 
> Thanks.
> 
> ________________________________________
> From: de Beus, Eric [eric.deb...@xerox.com]
> Sent: Thursday, May 20, 2010 11:06 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Document rotates while merging
> 
> Miguel,
> 
> Scanners often create rotated pages, because the scanner actually
> creates an image with the scan lines running along the long edge
> of the sheet, and then rotates the page to compensate. You need
> to get the rotation of the pages from the PdfReader, and then
> apply that rotation in your call to AddTemplate, using the overloaded
> method that takes a transformation matrix.
> 
> - Eric
> 
> -----Original Message-----
> From: RivasAviles, Miguel [mailto:miguel.rivasavi...@fwisd.org]
> Sent: Thursday, May 20, 2010 8:44 AM
> To: 'itext-questions@lists.sourceforge.net'
> Subject: [iText-questions] Document rotates while merging
> 
> Hello,
> 
> I'm merging some pdf files using PdfReader but for some reason
documents
> that contains images (created from scanned documents) just rotates.
> Please see attachments.
> 
> I'm using a simple merging process.  Any Idea on what am I doing
wrong?
> 
> foreach (PdfReader pdfReader in readers) {
>         // Create a new page in the target for each source page.
>         while (pageOfCurrentReaderPDF < pdfReader.NumberOfPages)
>         {
>                 document.NewPage();
>                 pageOfCurrentReaderPDF++;
>                 currentPageNumber++;
>                 page = writer.GetImportedPage(pdfReader,
> pageOfCurrentReaderPDF);
>                 cb.AddTemplate(page, 0, 0);
> 
>                 // Code for pagination.
>                 if (paginate)
>                 {
>                         cb.BeginText();
>                         cb.SetFontAndSize(bf, 9);
>
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER,
> string.Format("{0} of {1}", currentPageNumber, totalPages), 520, 5,
0);
>                         cb.EndText();
>                 }
> 
>                 // Confidential notice
>                 cb.BeginText();
>                 cb.SetFontAndSize(bf, 30);
>                 cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT,
> "CONFIDENTIAL", 600, 300, 90);
>                 cb.EndText();
> 
>         }
>       pageOfCurrentReaderPDF = 0;
> }
> 
> 
> 
> 
> Thank you.
> 
> Miguel
> 
> 
>
------------------------------------------------------------------------
--
> ----
> 
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.itextpdf.com/book/
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
------------------------------------------------------------------------
--
> ----
> 
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.itextpdf.com/book/
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.819 / Virus Database: 271.1.1/2884 - Release Date:
05/20/10
> 23:26:00

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to