List of usage examples for com.itextpdf.text PageSize A4
Rectangle A4
To view the source code for com.itextpdf.text PageSize A4.
Click Source Link
From source file:com.rapidminer.gui.actions.ExportPdfAction.java
License:Open Source License
/** * Creates a pdf showing the given {@link Component} via {@link PdfTemplate} usage. * @param component/*from w w w .ja v a2s.c o m*/ * @param document * @param cb * @throws DocumentException */ private void createPdfViaTemplate(Component component, Document document, PdfContentByte cb) throws DocumentException { PdfTemplate tp = cb.createTemplate(500, PageSize.A4.getHeight() / 2); Graphics2D g2 = tp.createGraphics(500, PageSize.A4.getHeight() / 2); // special handling for charts as we only want to export the chart but not the control panel // chart cannot be scaled to size of component because otherwise we would break the chart aspect-ratio if (component.getClass().isAssignableFrom(JPanel.class)) { JPanel panel = (JPanel) component; if (panel.getLayout().getClass().isAssignableFrom(CardLayout.class)) { for (final Component comp : panel.getComponents()) { // iterate over all card components and see if there is a chart which would require special handling // if not we don't do anything in this loop and do the standard behavior at the bottom of the method if (comp.isVisible() && ChartConfigurationPanel.class.isAssignableFrom(comp.getClass())) { final ChartConfigurationPanel chartConfigPanel = (ChartConfigurationPanel) comp; // create new LinkAndBrushChartPanel with double buffering set to false to get vector graphic export // The real chart has to use double buffering for a) performance and b) zoom rectangle drawing LinkAndBrushChartPanel newLaBPanel = new LinkAndBrushChartPanel( chartConfigPanel.getPlotEngine().getChartPanel().getChart(), chartConfigPanel.getPlotEngine().getChartPanel().getWidth(), chartConfigPanel.getPlotEngine().getChartPanel().getHeight(), chartConfigPanel.getPlotEngine().getChartPanel().getMinimumDrawWidth(), chartConfigPanel.getPlotEngine().getChartPanel().getMinimumDrawHeight(), false, false); newLaBPanel.setSize(chartConfigPanel.getPlotEngine().getChartPanel().getSize()); newLaBPanel .setOverlayList(chartConfigPanel.getPlotEngine().getChartPanel().getOverlayList()); AffineTransform at = new AffineTransform(); double factor = 500d / chartConfigPanel.getPlotEngine().getChartPanel().getWidth(); at.scale(factor, factor); g2.transform(at); newLaBPanel.print(g2); g2.dispose(); document.add(new Paragraph(componentName)); document.add(Image.getInstance(tp)); return; } else if (comp.isVisible() && PlotterPanel.class.isAssignableFrom(comp.getClass())) { // special case for PlotterPanel as the Panel itself is wider than the plotter // not having a special case here results in the exported image being too wide (empty space to the left) final PlotterPanel plotterPanel = (PlotterPanel) comp; AffineTransform at = new AffineTransform(); double factor = 500d / plotterPanel.getPlotterComponent().getWidth(); at.scale(factor, factor); g2.transform(at); plotterPanel.print(g2); g2.dispose(); document.add(new Paragraph(componentName)); document.add(Image.getInstance(tp)); return; } } } } AffineTransform at = new AffineTransform(); double factor = 500d / component.getWidth(); at.scale(factor, factor); g2.transform(at); component.print(g2); g2.dispose(); document.add(new Paragraph(componentName)); document.add(Image.getInstance(tp)); }
From source file:com.rapidminer.gui.actions.ExportPdfAction.java
License:Open Source License
/** * Creates a pdf showing the given {@link PlotterTemplate} via {@link PdfTemplate} usage. * @param template/* w ww . j ava2 s . co m*/ * @param document * @param cb * @throws DocumentException */ private void createPdfViaTemplate(PlotterTemplate template, Document document, PdfContentByte cb) throws DocumentException { PdfTemplate tp = cb.createTemplate(500, PageSize.A4.getHeight() / 2); Graphics2D g2 = tp.createGraphics(500, PageSize.A4.getHeight() / 2); AffineTransform at = new AffineTransform(); double factor = 500d / template.getPlotEngine().getChartPanel().getWidth(); at.scale(factor, factor); g2.transform(at); template.getPlotEngine().getChartPanel().print(g2); g2.dispose(); document.add(new Paragraph(componentName)); document.add(Image.getInstance(tp)); }
From source file:com.skatettoo.reportes.Generador.java
public String generarPDF() throws Exception { try {// www. j av a2s . co m String path = FacesContext.getCurrentInstance().getExternalContext().getRealPath("img"); path = path.substring(0, path.indexOf("\\build")); path = path + "\\web\\img\\"; Document doc = new Document(PageSize.A4, 36, 36, 10, 10); PdfPTable tabla = new PdfPTable(4); PdfWriter.getInstance(doc, new FileOutputStream(path + "\\archivo\\reporte.pdf\\")); doc.open(); Image img = Image.getInstance(path + "Skatetoo4.png"); img.scaleAbsolute(40, 40); img.setAlignment(Element.ALIGN_LEFT); doc.add(img); doc.addTitle(this.titulo); doc.addAuthor("\n "); doc.addAuthor("\n "); doc.addAuthor("\n "); doc.addAuthor("\n "); tabla.setWidthPercentage(100); tabla.setWidths(new float[] { 1.4f, 0.8f, 0.8f, 0.8f }); Object font = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD, BaseColor.WHITE); PdfPCell cell = new PdfPCell(new Phrase("Reporte de tatuadores", (Font) font)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(0f); cell.setPaddingBottom(7f); cell.setBackgroundColor(new BaseColor(0, 0, 0)); cell.setBorder(0); cell.setBorderWidthBottom(2f); tabla.addCell(cell); tabla.addCell("Tatuador"); tabla.addCell("Cantidad de diseos"); tabla.addCell("Citas realizadas"); tabla.addCell("Noticias publicadas"); for (Usuario u : this.getUsu()) { tabla.addCell(u.getNombre() + " " + u.getApellido()); tabla.addCell(String.valueOf(u.getDisenioList().size())); tabla.addCell(String.valueOf(u.getCitaList1().size())); tabla.addCell(String.valueOf(u.getNoticiaList().size())); } doc.add(tabla); doc.bottomMargin(); /* doc.add(new Paragraph("Tatuador mas solicitado")); for(Usuario u : this.getUs()){ doc.add(new Paragraph(u.getNombre() + " " + u.getApellido())); }*/ doc.close(); FacesContext context = FacesContext.getCurrentInstance(); ExternalContext externalContext = context.getExternalContext(); externalContext.responseReset(); externalContext.setResponseContentType("application/pdf"); externalContext.setResponseHeader("Content-Disposition", "attachment;filename=\"reporte.pdf\""); FileInputStream inputStream = new FileInputStream(new File(path + "\\archivo\\reporte.pdf\\")); OutputStream outputStream = externalContext.getResponseOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } inputStream.close(); context.responseComplete(); } catch (Exception e) { throw e; } return ""; }
From source file:com.softwaremagico.tm.pdf.complete.CharacterSheet.java
License:Open Source License
@Override protected Rectangle getPageSize() { return PageSize.A4; }
From source file:com.softwaremagico.tm.pdf.small.SmallPartySheet.java
License:Open Source License
@Override protected Rectangle getPageSize() { return PageSize.A4.rotate(); }
From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private String createDocument(Document doc, PdfWriter docWriter, LicensePFEntity license) throws FileNotFoundException, DocumentException { String fileName = "Requerimento de Habilitao de PJ - Cnpj: " + license.getCompany().getCnpj() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();/*w w w . j a v a2s .c o m*/ doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle("Requerimento de Habilitao de PJ"); doc.setPageSize(PageSize.A4); // open document doc.open(); return fileName; }
From source file:com.solidmaps.webapp.report.LicenseCivilIncludeProductPDF.java
License:Open Source License
private String createDocument(Document doc, PdfWriter docWriter, LicensePCEntity license, String type) throws FileNotFoundException, DocumentException { String fileName = "Requerimento de " + type + " Licensa: " + license.getCompany().getCnpj() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();/*from w w w. j a va 2s.co m*/ doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle("Requerimento de " + type + " Licensa: " + license.getCompany().getCnpj()); doc.setPageSize(PageSize.A4); // open document doc.open(); return fileName; }
From source file:com.solidmaps.webapp.report.MapCivilPdfGenerator.java
License:Open Source License
private String createDocument(Document doc, PdfWriter docWriter) throws FileNotFoundException, DocumentException { String fileName = "Mapa - " + company.getCnpj() + " - " + mapProduct.getNumTrimester() + " " + mapProduct.getYear() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();/* w w w .j a v a 2 s . c om*/ doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle("Mapa de Produtos Controlados: " + company.getCnpjFormatted()); doc.setPageSize(PageSize.A4.rotate()); // open document doc.open(); return fileName; }
From source file:com.solidmaps.webapp.report.MapExercitoPdfGenerator.java
License:Open Source License
private String createDocument(Document doc, PdfWriter docWriter) throws FileNotFoundException, DocumentException { String fileName = "Mapa - " + company.getCnpj() + " - " + mapProduct.getNumTrimester() + " " + mapProduct.getYear() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("Solid Maps"); doc.addCreationDate();/*from w ww.jav a 2s . c o m*/ doc.addProducer(); doc.addCreator("solidmaps"); doc.addTitle("Mapa de Produtos Controlados: " + company.getCnpjFormatted()); doc.setPageSize(PageSize.A4.rotate()); // open document doc.open(); return fileName; }
From source file:com.solidmaps.webapp.report.RenovationRequireExercitoPDF.java
private String createDocument(Document doc, PdfWriter docWriter, LicenseEXEntity license) throws FileNotFoundException, DocumentException { String fileName = "REQUERIMENTO PARA CONCESSO E REVALIDAO DE CERTIFICADO DE REGISTRO " + license.getNumRegister() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();//w w w . ja v a 2s .c om doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle("REQUERIMENTO PARA CONCESSO E REVALIDAO DE CERTIFICADO DE REGISTRO " + license.getNumRegister() + ".pdf"); doc.setPageSize(PageSize.A4); // open document doc.open(); return fileName; }