List of usage examples for com.lowagie.text.pdf PdfDestination PdfDestination
public PdfDestination(int type, float left, float top, float zoom)
PdfDestination
. From source file:com.logiware.accounting.reports.ArDisputeReportCreator.java
private void init(String fileName) throws Exception { document = new Document(PageSize.A4); document.setMargins(5, 5, 5, 30);//from w w w .j a v a 2 s . c o m writer = PdfWriter.getInstance(document, new FileOutputStream(fileName)); writer.setPdfVersion(PdfWriter.PDF_VERSION_1_7); writer.setUserunit(1f); writer.setPageEvent(new ArDisputeReportCreator(arReportsForm, contextPath)); document.open(); writer.setOpenAction( PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.XYZ, -1, -1, 1f), writer)); }
From source file:com.qcadoo.report.api.pdf.ReportPdfView.java
License:Open Source License
@Override protected final void buildPdfDocument(final Map<String, Object> model, final Document document, final PdfWriter writer, final HttpServletRequest request, final HttpServletResponse response) { String fileName;/*from w w w . j a v a2s . co m*/ try { PdfAction ac = PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.XYZ, -1, -1, 1f), writer); writer.setOpenAction(ac); fileName = addContent(document, model, LocaleContextHolder.getLocale(), writer); } catch (DocumentException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } response.setHeader("Content-disposition", "inline; filename=" + fileName + "." + ReportService.ReportType.PDF.getExtension()); }
From source file:gov.utah.health.uper.reports.Registration.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws DocumentException { try {/* w ww. j a v a 2 s.c o m*/ Map<String, Object> dataCollections = (Map<String, Object>) model.get("formData"); ApplicationBean app = (ApplicationBean) dataCollections.get("application"); PatientBean pt = (PatientBean) dataCollections.get("patient"); setUpPage(document); buildHeader(document, app); buildPatient(document, pt); buildParent(document, pt); buildPhysician(document, pt); buildFooter(document); writer.setOpenAction( PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.XYZ, 0, 10000, 1), writer)); } catch (Exception e) { LOG.error("Exception was caught while preparing UPER Registration.", e); } }
From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java
License:Open Source License
private void createBookmark(String bookmark, float x, float y, float width, float height) { contentByte.localDestination(bookmark, new PdfDestination(PdfDestination.XYZ, -1, transformY(y), 0)); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
protected void drawAnchor(final RenderNode content) { if (content.isNodeVisible(getDrawArea()) == false) { return;//from w w w .ja v a 2 s . c o m } final String anchorName = (String) content.getStyleSheet().getStyleProperty(ElementStyleKeys.ANCHOR_NAME); if (anchorName == null) { return; } final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float upperY = translateX + (float) (globalHeight - StrictGeomUtility.toExternalValue(content.getY())); final float leftX = (float) (StrictGeomUtility.toExternalValue(content.getX())); final PdfDestination dest = new PdfDestination(PdfDestination.FIT, leftX, upperY, 0); writer.getDirectContent().localDestination(anchorName, dest); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
protected void drawBookmark(final RenderNode box, final String bookmark) { if (box.isNodeVisible(getDrawArea()) == false) { return;//from w w w. j a v a 2s. c om } final PdfOutline root = writer.getDirectContent().getRootOutline(); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float upperY = translateX + (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY())); final float leftX = (float) (StrictGeomUtility.toExternalValue(box.getX())); final PdfDestination dest = new PdfDestination(PdfDestination.FIT, leftX, upperY, 0); new PdfOutline(root, dest, bookmark); // destination will always point to the 'current' page // todo: Make this a hierarchy .. }
From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java
License:Open Source License
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result = null;//from w w w.ja va 2 s .co m PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); if (page != null) { int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } return result; }
From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java
License:Open Source License
private void writeBookmark(RenderingContext c, Box root, PdfOutline parent, Bookmark bookmark) { String href = bookmark.getHRef(); PdfDestination target = null;/* w w w .j av a 2 s .c om*/ if (href.length() > 0 && href.charAt(0) == '#') { Box box = _sharedContext.getBoxById(href.substring(1)); if (box != null) { PageBox page = root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() - page.getTop(); target = new PdfDestination(PdfDestination.XYZ, 0, normalizeY(distanceFromTop / _dotsPerPoint), 0); target.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } } if (target == null) { target = _defaultDestination; } PdfOutline outline = new PdfOutline(parent, target, bookmark.getName()); writeBookmarks(c, root, outline, bookmark.getChildren()); }