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.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java
private String createDocument(Document doc, PdfWriter docWriter, LicenseEXEntity license) throws FileNotFoundException, DocumentException { String fileName = "REQUERIMENTO PARA APOSTILAMENTO DE CERTIFICADO DE REGISTRO " + license.getNumRegister() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();/*from w w w.jav a 2s . c om*/ doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle( "REQUERIMENTO PARA APOSTILAMENTO DE CERTIFICADO DE REGISTRO " + license.getNumRegister() + ".pdf"); doc.setPageSize(PageSize.A4); // open document doc.open(); return fileName; }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private String createDocument(Document doc, PdfWriter docWriter, LicensePFEntity license) throws FileNotFoundException, DocumentException { String fileName = "Comunicado de alterao cadastral - Cnpj: " + license.getCompany().getCnpj() + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName)); // document header attributes doc.addAuthor("EnforceMaps"); doc.addCreationDate();/*from w w w.jav a 2 s . c o m*/ doc.addProducer(); doc.addCreator("EnforceMaps"); doc.addTitle("Comunicado de alterao cadastral: "); doc.setPageSize(PageSize.A4); // open document doc.open(); return fileName; }
From source file:com.swayam.bhasha.engine.io.writers.impl.PDFGenerator.java
License:Apache License
private void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException { Rectangle pageSize = PageSize.A4; if (pageDim.height > pageSize.getHeight()) { pageSize = new Rectangle(pageDim.width, pageDim.height); }//www. ja va2 s .c om Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS); FileOutputStream pdfStream = null; try { pdfStream = new FileOutputStream(fileName); PdfWriter.getInstance(pdfDoc, pdfStream); pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)"); pdfDoc.open(); List<Para> paraList = htmlDoc.getParaList(); for (Para para : paraList) { pdfDoc.add(getParagraph(para)); } pdfDoc.close(); } catch (Exception e) { throw new DocGenerationException(e); } finally { if (pdfStream != null) { try { pdfStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.swayam.bhasha.engine.io.writers.impl.PDFImageGenerator.java
License:Apache License
private void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException, IOException { BufferedImage image = getImage(pageDim, htmlDoc); /*/* w w w . ja v a 2 s. c o m*/ * ByteArrayOutputStream bos = new ByteArrayOutputStream(); * * ImageIO.write(image, "JPG", bos); * * byte[] imageData = bos.toByteArray(); * * System.out.println("PDFImageGenerator.makePDFPage() " + * imageData.length); */ Rectangle pageSize = PageSize.A4; if (image.getHeight() > pageSize.getHeight()) { pageSize = new Rectangle(image.getWidth(), image.getHeight()); } Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS); FileOutputStream pdfStream = null; try { pdfStream = new FileOutputStream(fileName); PdfWriter pdfWriter = PdfWriter.getInstance(pdfDoc, pdfStream); pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)"); pdfDoc.open(); PdfContentByte contentByte = pdfWriter.getDirectContent(); Image pdfImage = Image.getInstance(image, null); pdfImage.setAbsolutePosition(0, 0); contentByte.addImage(pdfImage); } catch (Exception e) { throw new DocGenerationException(e); } finally { pdfDoc.close(); if (pdfStream != null) { try { pdfStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.timesheet.export.AbstractITextPdfViewCustom.java
protected Document newDocument() { return new Document(PageSize.A4); }
From source file:com.tomasz.drag.triballocommanderro.controller.MakerPDF.java
public static void printToPDFBoss(ArrayList<Person> workers, EventGig event) throws IOException, DocumentException { String filename = event.getName() + " Boss" + ".pdf"; String path = event.getData() + " " + event.getName() + "//"; //Rectangle rect = new Rectangle(0, 595, 8, 0); Document document = new Document(PageSize.A4.rotate(), 0, 0, 0, 0); //Document document = new Document(rect); //document.setMargins(0, 0, 0, 0); BaseFont bf;//from ww w.j a v a2 s .c o m //BaseFont bf2; // bf = BaseFont.createFont("arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); bf = BaseFont.createFont("src\\main\\resources\\font\\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); //bf2 = BaseFont.createFont("src\\main\\resources\\font\\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); com.itextpdf.text.Font ft = new com.itextpdf.text.Font(bf, 9); //com.itextpdf.text.Font ft2 = new com.itextpdf.text.Font(bf2,9); PdfWriter.getInstance(document, new FileOutputStream(path + filename)); document.open(); Paragraph p = new Paragraph(event.getName() + " " + event.getData(), ft); p.setAlignment(Element.ALIGN_CENTER); document.add(p); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(workers.size() + 1); table.setWidthPercentage(98); PdfPCell cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); for (Person tempPerson : workers) { cell = new PdfPCell(new Paragraph(tempPerson.getName(), ft)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } if (event.isZaladunekScenaDach()) { cell = new PdfPCell(new Paragraph("Za. Sc./Dach", ft)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getZaladunekScenaDachWyplata() > 0) { cell = new PdfPCell( new Paragraph(String.format("%.2f", tempPerson.getZaladunekScenaDachWyplata()), ft)); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isZaladunekTechniki()) { cell = new PdfPCell(new Phrase("Za. Tech.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getZaladunekTechnikiWyplata() > 0) { cell = new PdfPCell( new Paragraph(String.format("%.2f", tempPerson.getZaladunekTechnikiWyplata()), ft)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isRozladunekScenaDach()) { cell = new PdfPCell(new Phrase("Roz Sc/Dach", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getRozladunekScenaDachWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getRozladunekScenaDachWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isRozladunekTechniki()) { cell = new PdfPCell(new Phrase("Roz. Tech.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getRozladunekTechnikiWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getRozladunekTechnikiWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isMontazDachu()) { cell = new PdfPCell(new Phrase("Mon. Dach", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getMontazDachuWyplata() > 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getMontazDachuWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isMontazDzwieku()) { cell = new PdfPCell(new Phrase("Mon. Dw.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getMontazDzwiekuWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getMontazDzwiekuWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isMontazSceny()) { cell = new PdfPCell(new Phrase("Mon. Sc.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getMontazScenyWyplata() > 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getMontazScenyWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isMontazSwiatla()) { cell = new PdfPCell(new Phrase("Mon. w.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getMontazSwiatlaWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getMontazSwiatlaWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isMontazTechniki()) { cell = new PdfPCell(new Phrase("Mon. Tech.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getMontazTechnikiWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getMontazTechnikiWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDemontazDachu()) { cell = new PdfPCell(new Phrase("Dem. Dach", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDemontazDachuWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getDemontazDachuWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDemontazDzwieku()) { cell = new PdfPCell(new Phrase("Dem. Dw.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDemontazDzwiekuWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getDemontazDzwiekuWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDemontazSceny()) { cell = new PdfPCell(new Phrase("Dem. Sc.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDemontazScenyWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getDemontazScenyWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDemontazSwiatla()) { cell = new PdfPCell(new Phrase("Dem. w.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDemontazSwiatlaWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getDemontazSwiatlaWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDemontazTechniki()) { cell = new PdfPCell(new Phrase("Dem. Tech.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDemontazTechnikiWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getDemontazTechnikiWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isDyzur()) { cell = new PdfPCell(new Phrase("Dyur", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getDyzurWyplata() > 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getDyzurWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase("")); table.addCell(cell); } } } if (event.isTechnikSceny()) { cell = new PdfPCell(new Phrase("Technik Sc.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getTechnikScenyWyplata() > 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getTechnikScenyWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isRealizacjaFOH()) { cell = new PdfPCell(new Phrase("Real. FOH", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getRealizacjaFOHWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getRealizacjaFOHWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isRealizacjaMON()) { cell = new PdfPCell(new Phrase("Real. MON", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getRealizacjaMONWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getRealizacjaMONWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (event.isRealizacjaSwiatla()) { cell = new PdfPCell(new Phrase("Real. w.", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getRealizacjaSwiatlaWyplata() > 0) { cell = new PdfPCell( new Phrase(String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } if (true) { cell = new PdfPCell(new Phrase("Premia", ft)); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getPremia() > 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getPremia()), ft)); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } } Paragraph ph = new Paragraph("Razem", ft); //cell = new PdfPCell(new Phrase(ph)); cell.addElement(ph); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); for (Person tempPerson : workers) { if (tempPerson.getSumaWyplata() >= 0) { cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getSumaWyplata()) + " z", ft)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(" ")); table.addCell(cell); } } // for (Object obj : table.getChunks()) { // if (obj instanceof PdfPCell) { // System.out.println("jest PdfCell"); // PdfPCell tempCell = (PdfPCell) obj; // tempCell.setVerticalAlignment(Element.ALIGN_CENTER); // //tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // } // // } table.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(table); document.close(); }
From source file:com.unicauca.coordinacionpis.managedbean.RegistroFormatoAController.java
public void agregarMetadatos() { // create document and writer Document document = new Document(PageSize.A4); PdfWriter writer;/*from w ww . j a v a2 s .c om*/ try { writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\aguaabril2016.pdf")); // add meta-data to pdf document.addAuthor("Memorynotfound"); document.addCreationDate(); document.addCreator("Memorynotfound.com"); document.addTitle("Add meta data to PDF"); document.addSubject("how to add meta data to pdf using itext"); document.addKeywords(metadatosAnteproyectos.getTitulo() + "," + metadatosAnteproyectos.getProfesor()); document.addLanguage(Locale.ENGLISH.getLanguage()); document.addHeader("type", "tutorial, example"); // add xmp meta data writer.createXmpMetadata(); document.open(); document.add(new Paragraph("Add meta-data to PDF using iText")); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.xhsoft.framework.common.file.PDFHandle.java
License:Open Source License
public static void createPDF(String fileName) { Document doc = new Document(PageSize.A4.rotate()); OutputStream os = null;//from w w w. java 2s .c o m try { os = new FileOutputStream(fileName); PdfWriter.getInstance(doc, os); doc.open(); doc.add(new Paragraph("Hello World ! ")); doc.close(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.xumpy.itext.services.TimeSheet.java
public OutputStream pdf(List<Jobs> jobs, OutputStream outputStream) throws DocumentException, BadElementException, IOException, URISyntaxException { Document document = new Document(PageSize.A4, 0, 0, 160, 220); PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open();/* www .ja va2s . co m*/ HeaderFooter event = new HeaderFooter(); event.setTableHeader(header()); event.setTableFooter(footer()); writer.setPageEvent(event); document.add(body(jobs)); document.close(); return outputStream; }
From source file:com.zaptech.pdfdemo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try {//from w ww.j a va2 s . c o m File sdCard = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/PDFDemo"); if (!sdCard.exists()) { sdCard.mkdirs(); } File file = new File(sdCard, "sample.pdf"); if (!file.exists()) { file.createNewFile(); } fileOutputStream = new FileOutputStream(file); Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); PdfWriter.getInstance(document, fileOutputStream); document.open(); addMetaData(document); addTitlePage(document); addContent(document); document.close(); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } }