Changeset 32524 in osm for applications/editors/josm/plugins/pdfimport
- Timestamp:
- 2016-07-02T02:48:15+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport
- Files:
-
- 11 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/.classpath
r32520 r32524 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="src" path="resources"/> 5 <classpathentry kind="src" path="test/unit"/> 5 6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> 6 7 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> … … 8 9 <classpathentry kind="lib" path="lib/jempbox-1.8.12.jar"/> 9 10 <classpathentry kind="lib" path="lib/pdfbox-1.8.12.jar"/> 11 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 10 12 <classpathentry kind="output" path="bin"/> 11 13 </classpath> -
applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java
r30701 r32524 5 5 import java.awt.geom.Rectangle2D; 6 6 import java.io.File; 7 import java.io.IOException; 7 8 import java.util.List; 8 9 … … 22 23 } 23 24 24 public void parse(File file, int maxPaths, ProgressMonitor monitor) throws Exception 25 { 26 monitor.beginTask(tr("Parsing PDF", 1)); 25 public void parse(File file, int maxPaths, ProgressMonitor monitor) throws IOException { 26 monitor.beginTask(tr("Parsing PDF", 1)); 27 27 28 file);28 try (PDDocument document = PDDocument.load(file)) { 29 29 30 if(document.isEncrypted()){31 32 30 if (document.isEncrypted()) { 31 throw new IllegalArgumentException(tr("Encrypted documents not supported.")); 32 } 33 33 34 34 List<?> allPages = document.getDocumentCatalog().getAllPages(); 35 35 36 if (allPages.size() != 1) { 37 throw new Exception(tr("The PDF file must have exactly one page.")); 38 } 36 if (allPages.size() != 1) { 37 throw new IllegalArgumentException(tr("The PDF file must have exactly one page.")); 38 } 39 40 PDPage page = (PDPage) allPages.get(0); 41 PDRectangle pageSize = page.findMediaBox(); 42 Integer rotationVal = page.getRotation(); 43 int rotation = 0; 44 if (rotationVal != null) { 45 rotation = rotationVal.intValue(); 46 } 47 48 new PageDrawer().drawPage(new GraphicsProcessor(target, rotation, maxPaths, monitor), page); 49 this.target.bounds = new Rectangle2D.Double( 50 pageSize.getLowerLeftX(), 51 pageSize.getLowerLeftY(), 52 pageSize.getWidth(), 53 pageSize.getHeight()); 54 } 39 55 40 PDPage page = (PDPage)allPages.get(0); 41 PDRectangle pageSize = page.findMediaBox(); 42 Integer rotationVal = page.getRotation(); 43 int rotation = 0; 44 if (rotationVal != null){ 45 rotation = rotationVal.intValue(); 46 } 47 48 GraphicsProcessor p = new GraphicsProcessor(target, rotation, maxPaths, monitor); 49 PageDrawer drawer = new PageDrawer(); 50 drawer.drawPage(p, page); 51 this.target.bounds = new Rectangle2D.Double(pageSize.getLowerLeftX(), pageSize.getLowerLeftY(), pageSize.getWidth(), pageSize.getHeight()); 52 53 monitor.finishTask(); 54 } 56 monitor.finishTask(); 57 } 55 58 }
Note:
See TracChangeset
for help on using the changeset viewer.