Sylvain Machefert wrote:
> No problem, I'll wait till tomorrow
You'll be amazed how simple this solution is compared to what you had.
Of course you'll have to apply small changes to rotate the pages in the
desired sense. In the example, I rotate every page of test.pdf 90 degrees.
package test;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfName;
import com.lowagie.text.pdf.PdfNumber;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
public class RotatePages {
public static void main(String[] args) {
try {
PdfDictionary pageDict;
int rot;
PdfReader reader = new PdfReader("test.pdf");
int n = reader.getNumberOfPages();
for (int i = 1; i <= n; i++) {
rot = reader.getPageRotation(i);
System.out.println("page " + i + ": " + rot + " degrees");
pageDict = reader.getPageN(i);
pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90));
}
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream("rotated.pdf"));
stamper.close();
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions