Package com.itextpdf.text

Examples of com.itextpdf.text.Document


        ResizeProcessor resizer = new ResizeProcessor(resizeParameters);
        RotateProcessor rotator = new RotateProcessor(rotateParameters);
        WatermarkProcessor watermarker = new WatermarkProcessor(watermarkParameters);

        try {
            Document doc = new Document();

            PdfWriter.getInstance(doc, new FileOutputStream(new File(applyFileNameMasks(outputPath, ((ImportedImage) model.get(0))))));
            doc.open();
           
            for(int i=0; i<modelSize; i++){
           
                String filepath = ((ImportedImage) model.get(i)).getPath();
                if(getExtension(filepath).equalsIgnoreCase("pdf")){
                    ArrayList<BufferedImage> extractedImages = (ArrayList<BufferedImage>) PDFToImage.getBImagesFromPDF(((ImportedImage) model.get(i)).getPath(), 1, Integer.MAX_VALUE);
                    for (BufferedImage currentImage : extractedImages) {
                        BufferedImage image = bufferedImageProcess(resizer, rotator, watermarker, currentImage);
                        image = bufferedImageProcess(resizer, rotator, watermarker, image);
                        addImageToPDDocument(doc, image);
                    }
                } else {
                    BufferedImage image = Utils.loadImage(filepath);
                    image = bufferedImageProcess(resizer, rotator, watermarker, image);
                    addImageToPDDocument(doc, image);
                }
               
                progressBar.showProgress(((ImportedImage) model.get(i)).getPath());
                progressBar.updateValue(true);
            }
           
            doc.close();
        } catch (DocumentException ex) {
            Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
        catch (IOException ex) {
            Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here


        ResizeProcessor resizer = new ResizeProcessor(resizeParameters);
        RotateProcessor rotator = new RotateProcessor(rotateParameters);
        WatermarkProcessor watermarker = new WatermarkProcessor(watermarkParameters);

        try {
            Document doc = new Document();
           
            PdfWriter.getInstance(doc, new FileOutputStream(new File(applyFileNameMasks(outputPath, importedImage))));
            doc.open();
           
            String filepath = importedImage.getPath();
            if (getExtension(filepath).equalsIgnoreCase("pdf")) {
                ArrayList<BufferedImage> extractedImages = (ArrayList<BufferedImage>) PDFToImage.getBImagesFromPDF(importedImage.getPath(), 1, Integer.MAX_VALUE);
                for (BufferedImage currentImage : extractedImages) {
                    BufferedImage image = bufferedImageProcess(resizer, rotator, watermarker, currentImage);
                    image = bufferedImageProcess(resizer, rotator, watermarker, image);
                    addImageToPDDocument(doc, image);
                }
            } else {
                BufferedImage image = Utils.loadImage(filepath);
                image = bufferedImageProcess(resizer, rotator, watermarker, image);
                addImageToPDDocument(doc, image);
            }
           
            doc.close();
        } catch (DocumentException ex) {
            Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

    for (int i = 0; i < pageCount; ++i) {
      Image img = TiffImage.getTiffImage(ra, i + 1);
      if (img != null) {
        try {
          // First - create a single PDF page from the tiff page.
          Document document = new Document(PageSize.A4, 0.0f, 0.0f, 0.0f, 0.0f);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PdfWriter.getInstance(document, baos);
          document.open();
          document.add(img);
          document.close();

          // Second - read the memory based PDF file and read the image. Write
          // this into PNG file.
          PdfReader reader = new PdfReader(baos.toByteArray());
          for (int j = 0; j < reader.getXrefSize(); j++) {
View Full Code Here

  public Reporter(OutputStream out, ProgressMonitor monitor, String title, String subtitle, int maxRecords) throws DocumentException
  {
    this.out = out;
    this.monitor = monitor;
    this.maxRecords = maxRecords;
    this.rpt = new Document();

    PdfWriter writer = PdfWriter.getInstance(rpt, out);
    rpt.setMargins(80, 30, 20, 45); // links, rechts, oben, unten

    if (this.monitor != null)
View Full Code Here

    @Override
    protected void createDocument() throws DocumentException,
            FileNotFoundException,
            IOException {
        this.document = new Document(PageSize.LEGAL);
        PdfWriter.getInstance(this.document,
                new FileOutputStream(this.file.getAbsoluteFile()));
        this.document.open();
        this.document.addTitle("SERVICIO UNIVERSITARIO DE SALUD");
        this.document.addSubject("Documento generado por Systole para el Servicio Universitario de Salud");
View Full Code Here

      // Asegura la existencia de la carpeta
      IOUtils.ensurePathExists(workspace.getServerContext().getRealPath(File.separator), path);

      // Convierte el c�digo XHTML a PDF
      Document document = new Document();
      InputStream stream = new ByteArrayInputStream(xhtml.getBytes());

      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileNamePath));
      document.open();
      XMLWorkerHelper.getInstance().parseXHtml(writer, document, stream);
      document.close();

      // Construye la URL de acceso al informe PDF generado
      URL url = new URL(workspace.getUrl());
      url.addFolderOrFile("reports");
      url.addFolderOrFile("temp");
View Full Code Here

    private UBL4JConfigurationBean ubl4JConfigurationBean;

    public PDFInvoiceRenderer(InvoiceType invoiceType, PDFInvoiceRendererBean invoiceRendererBean,
                              UBL4JConfigurationBean ubl4JConfigurationBean) {
        this.invoiceType = invoiceType;
        this.document = new Document();
        this.invoiceRendererBean = invoiceRendererBean;
        this.ubl4JConfigurationBean = ubl4JConfigurationBean;
        initLocaleFromSupplierOrDefaultConfig();
    }
View Full Code Here

      this.progress = progress;
      this.progressLabel = progressLabel;
      this.invoiceNumber = invoiceNumber;
      processMap(recordEntities);
     
      final Document document = new Document(PageSize.A4, 20, 20, 10, 10);
      PdfWriter.getInstance(document, new FileOutputStream(output));
      document.open();
     
      addMetaData(document);
      addTitle(document);
      addTable(document, skipEmptyRecords);
      addNotes(document);
      document.close();
    } catch (final Exception e) {
      e.printStackTrace();
      return null;
    }
    return output;
View Full Code Here

   
    return toRet;
  }
 
  public void print() {
    Document document = new Document();
        try {
            PdfWriter.getInstance(document,new FileOutputStream("Totaal.pdf"));
            document.open();
            PdfPTable pdfTable = new PdfPTable(table.getColumnCount());
            pdfTable.setLockedWidth(false);
            PdfPCell cell = new PdfPCell();
            Phrase phrase = null;
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell.setBorderWidthLeft(1);
            for(int i=0;i<table.getColumnCount();i++)
            {
                phrase = new Phrase(table.getColumnName(i));
                cell = new PdfPCell(phrase);
                cell.setBackgroundColor(new BaseColor(220, 220, 220));
                pdfTable.addCell(cell);
            }
            for(int i=0;i<table.getRowCount();++i)
            {
                for(int j=0;j<table.getColumnCount();++j)
                {
                    phrase = new Phrase(String.valueOf(table.getValueAt(i, j)));
                    cell = new PdfPCell(phrase);
                    pdfTable.addCell(cell);
                }
            }
            pdfTable.addCell("Totaal");
            pdfTable.addCell("");
            pdfTable.addCell(hoeveel + "");
            pdfTable.addCell("€" + DecimalPlaces.set2decimals(totaal));
            pdfTable.addCell(alBetaald + "");
            pdfTable.addCell("€" + DecimalPlaces.set2decimals(albetaald));
            pdfTable.addCell("€" + DecimalPlaces.set2decimals(subtotaal));
            pdfTable.setHeaderRows(1);
            pdfTable.normalizeHeadersFooters();
            document.add(pdfTable);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        } catch (DocumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        }
        document.close();
        JOptionPane.showMessageDialog(null, "PDF 'Totaal.pdf' aangemaakt");
  }
View Full Code Here

    private static byte[] createPdf(final Font font)
      throws Exception
    {
      final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();

      final Document document = new Document();
      PdfWriter.getInstance(document, byteStream);
      document.open();
      document.add(new Paragraph(TEXT1, font));
      document.newPage();
      document.add(new Paragraph(TEXT2, font));
      document.close();

      final byte[] pdfBytes = byteStream.toByteArray();
     
      return pdfBytes;
    }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.