diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/oberdiek/test/ExtractRotate.java')
-rw-r--r-- | Master/texmf-dist/doc/latex/oberdiek/test/ExtractRotate.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/oberdiek/test/ExtractRotate.java b/Master/texmf-dist/doc/latex/oberdiek/test/ExtractRotate.java new file mode 100644 index 00000000000..c65ee28a2df --- /dev/null +++ b/Master/texmf-dist/doc/latex/oberdiek/test/ExtractRotate.java @@ -0,0 +1,48 @@ +/** + * ExtractRotate.java + * + * Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de> + * + * Requires: PDFBox (http://www.pdfbox.org/) + * + * Syntax: java ExtractRotate <pdffile> <textfile> + * + * The <pdffile> is analyzed and for each page its rotation + * setting is printed in the <textfile>. Example: + * /Page 1 /Rotate 0 + * /Page 2 /Rotate 90 + */ +import java.io.FileInputStream; +import java.io.FileWriter; +import org.pdfbox.pdfparser.PDFParser; +import org.pdfbox.pdmodel.PDDocument; +import org.pdfbox.pdmodel.PDDocumentCatalog; +import org.pdfbox.pdmodel.PDPage; + +public class ExtractRotate { + + public static void main(String[] args) { + try { + String infile = args[0]; + String outfile = args[1]; + FileWriter out = new FileWriter(outfile); + PDFParser parser = + new PDFParser(new FileInputStream(infile)); + parser.parse(); + PDDocument document = parser.getPDDocument(); + PDDocumentCatalog catalog = document.getDocumentCatalog(); + int i = 0; + for (Object page: catalog.getAllPages()) { + i++; + out.write("/Page " + i + " " + "/Rotate " + + ((PDPage)page).findRotation() + "\n"); + } + document.close(); + out.close(); + } + catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } +} |