public static void renderToPng(XDGFPage page, File outFile, double scale, ShapeRenderer renderer) throws IOException { Dimension2dDouble sz = page.getPageSize(); page.getContent().visitShapes(renderer);
public static void printHierarchy(XDGFPage page, File outDir) throws FileNotFoundException, UnsupportedEncodingException, IOException { File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".txt"); try ( OutputStream os = new FileOutputStream(pageFile); PrintStream pos = new PrintStream(os, false, "utf-8") ) { printHierarchy(page, pos); } }
/** * @return bounding box of page */ public Rectangle2D getBoundingBox() { Dimension2dDouble sz = getPageSize(); Point2D.Double offset = getPageOffset(); return new Rectangle2D.Double(-offset.getX(), -offset.getY(), sz.getWidth(), sz.getHeight()); } }
public static void printHierarchy(XDGFPage page, final PrintStream os) { page.getContent().visitShapes(new ShapeVisitor() { @Override public void visit(XDGFShape shape, AffineTransform globalTransform, int level) { for (int i = 0; i < level; i++) { os.append(" "); } // TODO: write text? os.println(shape + " [" + shape.getShapeType() + ", " + shape.getSymbolName() + "] " + shape.getMasterShape() + " " + shape.getTextAsString().trim()); } }); }
@Override protected void onDocumentRead() { try { try { _pagesObject = PagesDocument.Factory.parse(getPackagePart().getInputStream()).getPages(); } catch (XmlException | IOException e) { throw new POIXMLException(e); } // this iteration is ordered by page number for (PageType pageSettings: _pagesObject.getPageArray()) { String relId = pageSettings.getRel().getId(); POIXMLDocumentPart pageContentsPart = getRelationById(relId); if (pageContentsPart == null) throw new POIXMLException("PageSettings relationship for " + relId + " not found"); if (!(pageContentsPart instanceof XDGFPageContents)) throw new POIXMLException("Unexpected pages relationship for " + relId + ": " + pageContentsPart); XDGFPageContents contents = (XDGFPageContents)pageContentsPart; XDGFPage page = new XDGFPage(pageSettings, contents, _document, this); contents.onDocumentRead(); _pages.add(page); } } catch (POIXMLException e) { throw XDGFException.wrap(this, e); } }
public String getText() { ShapeTextVisitor visitor = new ShapeTextVisitor(); for (XDGFPage page: document.getPages()) { page.getContent().visitShapes(visitor); } return visitor.getText(); }
@Override protected void onDocumentRead() { try { try { _pagesObject = PagesDocument.Factory.parse(getPackagePart().getInputStream()).getPages(); } catch (XmlException | IOException e) { throw new POIXMLException(e); } // this iteration is ordered by page number for (PageType pageSettings: _pagesObject.getPageArray()) { String relId = pageSettings.getRel().getId(); POIXMLDocumentPart pageContentsPart = getRelationById(relId); if (pageContentsPart == null) throw new POIXMLException("PageSettings relationship for " + relId + " not found"); if (!(pageContentsPart instanceof XDGFPageContents)) throw new POIXMLException("Unexpected pages relationship for " + relId + ": " + pageContentsPart); XDGFPageContents contents = (XDGFPageContents)pageContentsPart; XDGFPage page = new XDGFPage(pageSettings, contents, _document, this); contents.onDocumentRead(); _pages.add(page); } } catch (POIXMLException e) { throw XDGFException.wrap(this, e); } }
public static void renderToPngDir(XDGFPage page, File outDir, double scale, ShapeRenderer renderer) throws IOException { File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".png"); System.out.println("** Writing image to " + pageFile); renderToPng(page, pageFile, scale, renderer); }
/** * @return bounding box of page */ public Rectangle2D getBoundingBox() { Dimension2dDouble sz = getPageSize(); Point2D.Double offset = getPageOffset(); return new Rectangle2D.Double(-offset.getX(), -offset.getY(), sz.getWidth(), sz.getHeight()); } }
public static void renderToPng(XDGFPage page, File outFile, double scale, ShapeRenderer renderer) throws IOException { Dimension2dDouble sz = page.getPageSize(); page.getContent().visitShapes(renderer);
public static void printHierarchy(XDGFPage page, final PrintStream os) { page.getContent().visitShapes(new ShapeVisitor() { @Override public void visit(XDGFShape shape, AffineTransform globalTransform, int level) { for (int i = 0; i < level; i++) { os.append(" "); } // TODO: write text? os.println(shape + " [" + shape.getShapeType() + ", " + shape.getSymbolName() + "] " + shape.getMasterShape() + " " + shape.getTextAsString().trim()); } }); }
public static void renderToPngDir(XDGFPage page, File outDir, double scale, ShapeRenderer renderer) throws IOException { File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".png"); System.out.println("** Writing image to " + pageFile); renderToPng(page, pageFile, scale, renderer); }
public String getText() { ShapeTextVisitor visitor = new ShapeTextVisitor(); for (XDGFPage page: document.getPages()) { page.getContent().visitShapes(visitor); } return visitor.getText(); }
public static void printHierarchy(XDGFPage page, File outDir) throws FileNotFoundException, UnsupportedEncodingException, IOException { File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".txt"); try ( OutputStream os = new FileOutputStream(pageFile); PrintStream pos = new PrintStream(os, false, "utf-8") ) { printHierarchy(page, pos); } }