List of usage examples for com.itextpdf.text Document open
boolean open
To view the source code for com.itextpdf.text Document open.
Click Source Link
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 ww . ja v a 2 s. c o m 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 ww w. ja v a 2s . c om*/ 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();/*from w w w. ja v a 2 s . c o m*/ 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; }
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 . j a va 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. j av a2 s . c om 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.sparksoftsolutions.com.pdfcreator.MainActivity.java
private File generatePDFFromImages(ArrayList<ImageItem> images) { Document document = new Document(); File sdcard = Environment.getExternalStorageDirectory(); File file = new File(sdcard, generateFileName()); try {/* www.ja v a2s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); } catch (Exception ex) { return null; } // document = new PdfDocument(); Boolean opened = false; for (ImageItem img : images) { Bitmap bitmap = BitmapFactory.decodeFile(img.path); try { Image image = Image.getInstance(img.path); document.setPageSize(new Rectangle(image.getWidth(), image.getHeight())); if (!opened) { document.open(); opened = true; } else document.newPage(); document.add(image); } catch (Exception e) { e.printStackTrace(); return null; } } document.close(); return file; }
From source file:com.sreekanth.duelist.FirstPdf.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first_pdf); try {//from www. j a v a2 s. c o m Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(yourFile)); document.open(); addMetaData(document); addTitlePage(document); addContent(document); document.close(); Toast.makeText(FirstPdf.this, "First Pdf File Created in download directory", Toast.LENGTH_LONG).show(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.suyati.androidpdf.FirstPDFActivity.java
public void PrintDocument(String dest) throws IOException, java.io.IOException { try {//from ww w. j a v a2 s . co m // Document document = new Document(); Document document = new Document(PageSize.PENGUIN_SMALL_PAPERBACK, 10f, 10f, 100f, 0f);//PENGUIN_SMALL_PAPERBACK used to set the paper size PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); addMetaData(document); addTitlePage(document); addContent(document); document.close(); File file = new File(dest); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
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); }/*from w w w. j a v a2s. c o m*/ 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 . j a va 2 s.co 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(); } } } }