I need create copy of pdf file with one or more pages
rotated by 90, 180 and 270 degrees.
My function to rotate by 90 degreeslooks like:
// create pdf reader
reader = new PdfReader(inputFile.getCanonicalPath());
// get number of pages in input file
pagesNumber = reader.getNumberOfPages();
for (int index = 1; index <= pagesNumber; index++)
{
currPageRect =
reader.getPageSizeWithRotation(index);
if (outputFileDocument == null)
{
// create document and set first page size and
rotation
outputFileDocument = new
Document(currPageRect.rotate());
destFileStream = new
FileOutputStream(outputFile.getCanonicalPath());
// open output file
pdfCopy =
PdfWriter.getInstance(outputFileDocument,
destFileStream);
// open output pdf document
outputFileDocument.open();
cb = pdfCopy.getDirectContent();
}
// get page from source document
importedPage = pdfCopy.getImportedPage(reader,
index);
// create new page in outpu pdf file
outputFileDocument.setPageSize(currPageRect.rotate());
outputFileDocument.newPage();
// set transformation matrix to rotate right and
move result to first
// quadrant
cb.addTemplate(
importedPage,
0.0f,
-1.0f,
1.0f,
0.0f,
0.0f,
reader.getPageSizeWithRotation(index).width()
);
}
// finish
outputFileDocument.close();
It works fine for first time but if I use this
function on output pdf (from this function),
page backround is rotated by 180 degrees but imported
page is rotated only by 90 degrees.
Thanks for any help,
Martin Cerba.
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions