PDDocument doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage( page ); PDPageContentStream contentStream = new PDPageContentStream(doc, page); String[][] content = {{"a","b", "1"}, {"c","d", "2"}, {"e","f", "3"}, {"g","h", "4"}, {"i","j", "5"}} ; drawTable(page, contentStream, 700, 100, content); contentStream.close(); doc.save("test.pdf" );
String title = "This is my wonderful title!"; // Or whatever title you want. int marginTop = 30; // Or whatever margin you want. PDDocument document = new PDDocument(); PDPage page = new PDPage() PDPageStreamContent stream = new PDPageContentStream(document, page); PDFont font = PDType1Font.HELVETICA_BOLD; // Or whatever font you want. int fontSize = 16; // Or whatever font size you want. float titleWidth = font.getStringWidth(title) / 1000 * fontSize; float titleHeight = font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize; stream.beginText(); stream.setFont(font, fontSize); stream.moveTextPositionByAmount((page.getMediaBox().getWidth() - titleWidth) / 2, page.getMediaBox().getHeight - marginTop - titleheight); stream.drawString(title); stream.endText(); stream.close();
PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(doc, page);
PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(doc, page);
@Override public PDPage next() { COSDictionary next = queue.poll(); sanitizeType(next); ResourceCache resourceCache = document != null ? document.getResourceCache() : null; return new PDPage(next, resourceCache); }
public void showType3Character(PDType3CharProc charProc) throws IOException { processChildStream(charProc, new PDPage()); // dummy page (resource lookup may fail) }
/** * Get the page that this bead is part of. * * @return The page that this bead is part of. */ public PDPage getPage() { PDPage page = null; COSDictionary dic = (COSDictionary)bead.getDictionaryObject( "P" ); if( dic != null ) { page = new PDPage( dic ); } return page; }
/** * Gets the page. * * @return the page */ public PDPage getPage() { COSDictionary pg = (COSDictionary) this.getCOSObject().getDictionaryObject(COSName.PG); if (pg != null) { return new PDPage(pg); } return null; }
/** * This will retrieve the corresponding page of this annotation. * * @return the corresponding page */ public PDPage getPage() { COSBase base = this.getCOSObject().getDictionaryObject(COSName.P); if (base instanceof COSDictionary) { return new PDPage((COSDictionary) base); } return null; }
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("usage: " + CreateBlankPDF.class.getName() + " <outputfile.pdf>"); System.exit(1); } String filename = args[0]; try (PDDocument doc = new PDDocument()) { // a valid PDF document requires at least one page PDPage blankPage = new PDPage(); doc.addPage(blankPage); doc.save(filename); } } }
/** * Returns the page on which some or all of the content items designated by * the K entry shall be rendered (Pg). * * @return the page on which some or all of the content items designated by * the K entry shall be rendered */ public PDPage getPage() { COSBase base = this.getCOSObject().getDictionaryObject(COSName.PG); if (base instanceof COSDictionary) { return new PDPage((COSDictionary) base); } return null; }
/** * This will get the page for this destination. A page destination can either reference a page * (for a local destination) or a page number (when doing a remote destination to another PDF). * If this object is referencing by page number then this method will return null and * {@link #getPageNumber()} should be used. * * @return The page for this destination. */ public PDPage getPage() { PDPage retval = null; if( array.size() > 0 ) { COSBase page = array.getObject( 0 ); if( page instanceof COSDictionary ) { retval = new PDPage( (COSDictionary)page ); } } return retval; }
/** * Returns the page at the given index. * * @param index zero-based index */ public PDPage get(int index) { COSDictionary dict = get(index + 1, root, 0); sanitizeType(dict); ResourceCache resourceCache = document != null ? document.getResourceCache() : null; return new PDPage(dict, resourceCache); }
public static void main(String[] args) throws IOException, COSVisitorException { PDDocument doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage( page ); PDPageContentStream contentStream = new PDPageContentStream(doc, page); String[][] content = { {"Name"," Time "}, {"HTC","01:25"}, {"Samsung Tab2","05:30"} } ; drawTable(page, contentStream, 700, 100, content); contentStream.close(); doc.save("h:\\test.pdf" ); }
@Override public void createPage(PDVisibleSignDesigner properties) { PDPage page = new PDPage(new PDRectangle(properties.getPageWidth(), properties.getPageHeight())); pdfStructure.setPage(page); LOG.info("PDF page has been created"); }
public PagePane(PDDocument document, COSDictionary pageDict, JLabel statuslabel) { page = new PDPage(pageDict); pageIndex = document.getPages().indexOf(page); this.document = document; this.statuslabel = statuslabel; initUI(); initRectMap(); }
PDPage page = new PDPage(); doc.addPage(page);
PDPage page = new PDPage(); doc.addPage(page);
/** * Process the validation of a XObject Form * * @param form the PDFormXObject to be validated. * @throws ValidationException */ public void validateXObjContentStream(PDFormXObject form) throws ValidationException { try { // workaround for preflight not finding widget annotation parent PDPage if (processedPage == null) { // dummy page, resource lookup may fail processChildStream(form, new PDPage()); } else { processChildStream(form, processedPage); } } catch (ContentStreamException e) { context.addValidationError(new ValidationError(e.getErrorCode(), e.getMessage())); } catch (IOException e) { throw new ValidationException("Unable to check the XObject ContentStream : " + e.getMessage(), e); } }
PDPage page = new PDPage(); doc.addPage(page);