Example usage for com.itextpdf.text Document Document

List of usage examples for com.itextpdf.text Document Document

Introduction

In this page you can find the example usage for com.itextpdf.text Document Document.

Prototype


public Document() 

Source Link

Document

Constructs a new Document -object.

Usage

From source file:com.thelinh.gui.UpdateChap.java

private void btnPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPdfActionPerformed
    Document document = new Document() {
    };//from  w  ww . ja va 2 s . c  o  m
    try {
        JFileChooser jfc = new JFileChooser("Save File");
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            jfc.setDialogTitle("Save File");
            FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
            PdfWriter.getInstance(document, fos);
            document.open();
            Font rfont = FontFactory.getFont("C:\\Windows\\Fonts\\Calibri.ttf", IDENTITY_H, true);
            document.add(new Paragraph(
                    "                                                                TRNG ?I HC B?CH KHOA H NI",
                    rfont));
            document.add(new Paragraph(
                    "                                                            KT QU TM KIM C?C CHNG CA MN HC\n",
                    rfont));
            document.add(new Paragraph(
                    "                Tm kim theo m mn h?c : " + txtSearch.getText() + "\n\n",
                    rfont));

            TableModel tableModel = tbChap.getModel();
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                String subject = (String) tableModel.getValueAt(i, 0) + " : "
                        + (String) tableModel.getValueAt(i, 1) + "\n\n";
                String id = (String) tableModel.getValueAt(i, 0);
                String id1 = id;
                document.add(new Paragraph(subject, rfont));
                PdfPTable table = new PdfPTable(2);
                PdfPCell header1 = new PdfPCell(new Paragraph("Chapter", rfont));
                PdfPCell header2 = new PdfPCell(new Paragraph("ChapterName", rfont));
                table.addCell(header1);
                table.addCell(header2);
                while (id.equals(id1) && i < tableModel.getRowCount()) {
                    table.addCell(
                            new PdfPCell(new Paragraph(String.valueOf(tableModel.getValueAt(i, 2)), rfont)));
                    table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 3), rfont)));
                    i++;
                    if (i < tableModel.getRowCount())
                        id1 = (String) tableModel.getValueAt(i, 0);
                }
                document.add(table);
                document.add(new Paragraph("\n"));

            }

            document.add(new Paragraph(
                    "\n                                                                                                      Ha Noi, November 4th, 2016\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                                Teacher\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                            (Signed and Sealed)\n",
                    rfont));

            document.close();
            JOptionPane.showMessageDialog(null, "Save success");
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.thelinh.gui.UpdateQuestion.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    Document document = new Document() {
    };/*from   www .  j a  v a2  s.  c o m*/
    try {
        JFileChooser jfc = new JFileChooser("Save File");
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            jfc.setDialogTitle("Save File");
            FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
            PdfWriter.getInstance(document, fos);
            document.open();
            Font rfont = FontFactory.getFont("C:\\Windows\\Fonts\\Calibri.ttf", IDENTITY_H, true);
            document.add(new Paragraph(
                    "                                                TRNG ?I HC B?CH KHOA H NI",
                    rfont));
            document.add(new Paragraph(
                    "\t\t                                                            KT QU TM KIM CU HI\n",
                    rfont));
            switch (k) {
            case 1:
                document.add(new Paragraph(
                        "                Tm kim theo QuestionId : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            case 2:
                document.add(new Paragraph("                Tm kim theo ni dung cu h?i : "
                        + txtSearch.getText() + "\n\n", rfont));
                break;
            case 3:
                document.add(new Paragraph(
                        "                Tm kim theo level : " + txtSearch.getText() + "\n\n", rfont));
                break;
            case 4:
                document.add(new Paragraph(
                        "                Tm kim theo m mn h?c : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            case 5:
                document.add(new Paragraph(
                        "                Tm kim theo cu tr l?i : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            }

            TableModel tableModel = tbQuestion.getModel();
            int question = 1;
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                String id = (String) tableModel.getValueAt(i, 0);
                document.add(new Paragraph("\nCu " + question + " : ", rfont));
                document.add(new Paragraph((String) tableModel.getValueAt(i, 1) + "\n\n", rfont));
                PdfPTable table = new PdfPTable(3);
                PdfPCell header1 = new PdfPCell(new Paragraph("?p n s", rfont));
                PdfPCell header2 = new PdfPCell(new Paragraph("Ni dung p n", rfont));
                PdfPCell header3 = new PdfPCell(new Paragraph("?ng sai", rfont));
                table.addCell(header1);
                table.addCell(header2);
                table.addCell(header3);
                String id1 = id;
                char answer = 'A';
                while (id.equals(id1) && i < tableModel.getRowCount()) {
                    table.addCell(new PdfPCell(new Paragraph("" + answer)));
                    table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 6), rfont)));
                    table.addCell(
                            new PdfPCell(new Paragraph(String.valueOf(tableModel.getValueAt(i, 7)), rfont)));
                    i++;
                    if (i < tableModel.getRowCount())
                        id1 = (String) tableModel.getValueAt(i, 0);
                    answer++;
                }
                document.add(table);
                question++;

            }

            document.add(new Paragraph(
                    "\n                                                                                                  Ha Noi, November 4th, 2016\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                            Teacher\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                        (Signed and Sealed)\n",
                    rfont));

            document.close();
            JOptionPane.showMessageDialog(null, "Save success");
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.thelinh.gui.UpdateSubject.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    Document document = new Document() {
    };/* www.j a  va  2  s . c o m*/
    try {
        JFileChooser jfc = new JFileChooser("Save File");
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            jfc.setDialogTitle("Save File");
            FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
            PdfWriter.getInstance(document, fos);
            document.open();
            Font rfont = FontFactory.getFont("C:\\Windows\\Fonts\\Calibri.ttf", IDENTITY_H, true);
            document.add(new Paragraph(
                    "                                                                TRNG ?I HC B?CH KHOA H NI",
                    rfont));
            document.add(new Paragraph(
                    "\t\t                                                                    KT QU TM KIM MN HC\n",
                    rfont));
            switch (k) {
            case 1:
                document.add(new Paragraph(
                        "                Tm kim theo m mn h?c : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            case 2:
                document.add(new Paragraph(
                        "                Tm kim theo tn mn h?c : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            }
            PdfPTable table = new PdfPTable(2);
            PdfPCell header1 = new PdfPCell(new Paragraph("SubjectId", rfont));
            PdfPCell header2 = new PdfPCell(new Paragraph("SubjectName", rfont));

            table.addCell(header1);
            table.addCell(header2);

            TableModel tableModel = tbSubject.getModel();
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 0), rfont)));
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 1), rfont)));

            }
            document.add(table);
            document.add(new Paragraph(
                    "\n                                                                                              Ha Noi, November 4th, 2016\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                        Teacher\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                    (Signed and Sealed)\n",
                    rfont));

            document.close();
            JOptionPane.showMessageDialog(null, "Save success");
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.thelinh.gui.UpdateUser.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    Document document = new Document() {
    };/*from w w  w  .  j a  v a2 s  .  c  om*/
    try {
        JFileChooser jfc = new JFileChooser("Save File");
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            jfc.setDialogTitle("Save File");
            FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
            PdfWriter.getInstance(document, fos);
            document.open();
            Font rfont = FontFactory.getFont("C:\\Windows\\Fonts\\Calibri.ttf", IDENTITY_H, true);
            document.add(new Paragraph(
                    "                                                                TRNG ?I HC B?CH KHOA H NI",
                    rfont));
            document.add(new Paragraph(
                    "\t\t                                                                        KT QU TM KIM NGI DNG\n",
                    rfont));
            switch (k) {
            case 1:
                document.add(new Paragraph(
                        "                Tm kim theo m ng?i dng : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            case 2:
                document.add(new Paragraph(
                        "                Tm kim theo mt khu : " + txtSearch.getText() + "\n\n",
                        rfont));
                break;
            case 3:
                document.add(new Paragraph("                Tm kim theo tn ng?i dng : "
                        + txtSearch.getText() + "\n\n", rfont));
                break;
            case 4:
                document.add(new Paragraph(
                        "                Tm kim theo lp :" + txtSearch.getText() + "\n\n", rfont));
                break;
            }
            PdfPTable table = new PdfPTable(5);
            PdfPCell header1 = new PdfPCell(new Paragraph("UserId", rfont));
            PdfPCell header2 = new PdfPCell(new Paragraph("Password", rfont));
            PdfPCell header3 = new PdfPCell(new Paragraph("UserName", rfont));
            PdfPCell header4 = new PdfPCell(new Paragraph("BirthDay", rfont));
            PdfPCell header5 = new PdfPCell(new Paragraph("Class", rfont));
            table.addCell(header1);
            table.addCell(header2);
            table.addCell(header3);
            table.addCell(header4);
            table.addCell(header5);

            TableModel tableModel = tbUser.getModel();
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 0), rfont)));
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 1), rfont)));
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 2), rfont)));
                SimpleDateFormat sdf = new SimpleDateFormat();
                table.addCell(new PdfPCell(new Paragraph(sdf.format(tableModel.getValueAt(i, 3)), rfont)));
                table.addCell(new PdfPCell(new Paragraph((String) tableModel.getValueAt(i, 4), rfont)));
            }
            document.add(table);
            document.add(new Paragraph(
                    "\n                                                                                          Ha Noi, November 4th, 2016\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                    Teacher\n",
                    rfont));
            document.add(new Paragraph(
                    "                                                                                                (Signed and Sealed)\n",
                    rfont));

            document.close();
            JOptionPane.showMessageDialog(null, "Save success");
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.thelinh.views.Statistics.java

private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
    Document document = new Document() {
    };/*from   w  ww .  j a  v a  2 s. c o  m*/
    try {
        JFileChooser jfc = new JFileChooser("Save File");
        if (jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            String content = this.taReport.getText();
            jfc.setDialogTitle("Save File");
            FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
            PdfWriter.getInstance(document, fos);
            document.open();
            document.add(new Paragraph(content));
            document.close();
            JOptionPane.showMessageDialog(null, "Save success");
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(Statistics.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.thomasmore.service.PdfCreateServiceImpl.java

public void readPdf() {
    try {//from  w  w  w . j a v  a 2 s  . co m
        OutputStream file = new FileOutputStream(new File("D:\\SamplePDFje.pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        document.add(new Paragraph("First iText PDF"));
        document.add(new Paragraph(new Date().toString()));

        document.addAuthor("Krishna Sfsfsfsn");
        document.addCreationDate();
        document.addCreator("JavaBeat");
        document.addTitle("Sample PDF");

        //Create Paragraph
        Paragraph paragraph = new Paragraph("Title 1", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));

        //New line
        paragraph.add(new Paragraph(" "));
        paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        //Create a table in PDF
        PdfPTable pdfTable = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Phrase("Table Header 1"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 2"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 3"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);
        pdfTable.setHeaderRows(1);

        pdfTable.addCell("Row 1 Col 1");
        pdfTable.addCell("Row 1 Col 2");
        pdfTable.addCell("Row 1 Col 3");

        pdfTable.addCell("Row 2 Col 1");
        pdfTable.addCell("Row 2 Col 2");
        pdfTable.addCell("Row 2 Col 3");

        document.add(pdfTable);

        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:com.tomasz.drag.triballocommanderro.controller.MakerPDF.java

public static void printToPDF(ArrayList<Person> workers, EventGig event) throws IOException, DocumentException {
    String filename = event.getName() + ".pdf";
    String path = event.getData() + " " + event.getName() + "//";

    Document document = new Document();
    // step 2/*w  w  w  .j  a v  a  2s .  com*/
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path + filename));
    // step 3
    document.open();
    // step 4
    ColumnText column = new ColumnText(writer.getDirectContent());

    float[][] x = { { document.left(), document.left() + 230 }, { document.right() - 230, document.right() } };
    for (Person person : workers) {
        column.addElement(MakerPDF.createTable(person, event));
    }
    int count = 0;
    float height = 0;
    int status = ColumnText.START_COLUMN;
    while (ColumnText.hasMoreText(status)) {
        column.setSimpleColumn(x[count][0], document.bottom(), x[count][1], document.top() - height - 10);
        // render as much content as possible
        status = column.go();
        // go to a new page if you've reached the last column
        if (++count > 1) {
            count = 0;
            document.newPage();
        }
    }
    document.newPage();
    document.close();
}

From source file:com.tommontom.pdfsplitter.PdfCombine.java

public List<File> combine(File folder) throws IOException, DocumentException {
    if (!folder.isDirectory()) {
        throw new IllegalArgumentException("Provided folder is not a directory: " + folder);
    }//from   ww w.j a va  2 s  .  c o  m
    FileNameFilter FileFilter = new FileNameFilter();
    File[] listOfFiles = folder.listFiles(FileFilter);

    /*
     * Stores the listing of the files
     */
    List<File> newFileList = new ArrayList<>();
    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }

        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf('.'));

        // Split on a space '\s'
        String[] fileNames = fileNameWithoutExt.split("\\s");
        if (fileNames.length != 2) {
            throw new RuntimeException("File name format is not in right format");
        }

        String fileNameFirst = fileNames[0];
        String fileNameSecond = fileNames[1];
        System.out.println("First lot number: " + fileNameFirst + " Second lot number: " + fileNameSecond);
        String[] fileNameFirstParts = fileNameFirst.split("-");

        // Project num is always the 1st part
        String projectNum = fileNameFirstParts[0];
        if (!projectNum.equals(fileNameFirstParts[0])) {
            throw new RuntimeException("Filename needs to be renamed to the correct format");
        }
        // Strip off the first and second lot number, parse into integers
        int firstLotNum;
        int secondLotNum;
        firstLotNum = Integer.parseInt(fileNameFirstParts[1]);
        secondLotNum = Integer.parseInt(fileNameFirstParts[2]);

        // Determine number of pages by difference of lot numbers

        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf,
        // 16034-212235.pdf, 16034-212236.pdf
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        int mod = pdfFileReader.getNumberOfPages() % 2;
        if (pdfFileReader.equals(mod)) {
            throw new RuntimeException("File is not an even number of pages");
        }
        Document document = new Document();

        /*
         * instantiates a new document to be made
         */
        int numPages = pdfFileReader.getNumberOfPages();
        int p = 0;
        int j = 0;
        // Create a copy of the orignal source file. We will pick specific pages
        // out below
        document.open();
        while (j < numPages) {
            if (p == numPages) {
                break;
            }
            if (j % 2 == 2) {
                j += 1;
            }
            j += 1;
            firstLotNum++;

            // Dynamic filename
            String dynamicFileName = projectNum + "-" + (firstLotNum - 1) + ".pdf";
            document = new Document();
            PdfCopy copy = new PdfCopy(document,
                    new FileOutputStream(folder.getPath() + "\\" + dynamicFileName));
            document.open();
            p += 2;

            // Import pages from original doc
            copy.addPage(copy.getImportedPage(pdfFileReader, j));
            copy.addPage(copy.getImportedPage(pdfFileReader, p));
            document.close();

            // Add to the list of compled file names
            newFileList.add(new File(dynamicFileName));
        }
        System.out.println("Number of Documents Created:" + numPages);
        System.out.println("Number of Documents Created:" + listOfFiles[i]);
    }

    return newFileList;
}

From source file:com.unicauca.coordinacionpis.managedbean.RegistroFormatoAController.java

public void aceptarFormatoA() {

    boolean existe = false;
    boolean existeFolderCoordinacion = false;
    Document okmDocument = new Document();
    try {//  w  w w.j a  va  2s  . co m

        for (Folder fld : okm.getFolderChildren("/okm:root")) {
            if (fld.getPath().equalsIgnoreCase("/okm:root/Coordinacion")) {

                existeFolderCoordinacion = true;
            }
        }
        if (existeFolderCoordinacion) {
            for (Folder fld : okm.getFolderChildren("/okm:root/Coordinacion")) {
                if (fld.getPath().equalsIgnoreCase("/okm:root/Coordinacion/FormatoA")) {
                    existe = true;
                }
            }
        } else {
            okm.createFolderSimple("/okm:root/Coordinacion");
        }

        if (!existe) {
            okm.createFolderSimple("/okm:root/Coordinacion/FormatoA");
            okm.createDocumentSimple("/okm:root/Coordinacion/FormatoA/" + archivOferta.getFileName(),
                    archivOferta.getInputstream());
        } else {
            okm.createDocumentSimple("/okm:root/Coordinacion/FormatoA/" + archivOferta.getFileName(),
                    archivOferta.getInputstream());
        }
        okm.addGroup("/okm:root/Coordinacion/FormatoA/" + archivOferta.getFileName(), "okg:FormatoA");

        List<FormElement> fElements = okm.getPropertyGroupProperties(
                "/okm:root/Coordinacion/FormatoA/" + archivOferta.getFileName(), "okg:FormatoA");
        for (FormElement fElement : fElements) {
            if (fElement.getName().equals("okp:FormatoA.docente")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getProfesor());
            }
            if (fElement.getName().equals("okp:FormatoA.TituloAnteproyecto")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getTitulo());
            }
            if (fElement.getName().equals("okp:FormatoA.Fecha")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getFecha());
            }

            if (fElement.getName().equals("okp:FormatoA.PrimerEstudiante")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getNombreEstudiante1());
            }
            if (fElement.getName().equals("okp:FormatoA.SegundoEstudiante")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getNombreEstudiante2());
            }
            if (fElement.getName().equals("okp:FormatoA.ActaAprobacion")) {
                Input name = (Input) fElement;
                name.setValue(this.metadatosAnteproyectos.getActaAprobacion());
            }
        }
        okm.setPropertyGroupProperties("/okm:root/Coordinacion/FormatoA/" + archivOferta.getFileName(),
                "okg:FormatoA", fElements);

    } catch (PathNotFoundException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RepositoryException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DatabaseException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnknowException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (WebserviceException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (AccessDeniedException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ItemExistsException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ExtensionException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (AutomationException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedMimeTypeException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileSizeExceededException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UserQuotaExceededException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (VirusDetectedException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchGroupException ex) {
        Logger.getLogger(RegistroFormatoAController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (LockException ex) {
        Logger.getLogger(RegistroFormatoAController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ParseException ex) {
        Logger.getLogger(RegistroFormatoAController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchPropertyException ex) {
        Logger.getLogger(RegistroFormatoAController.class.getName()).log(Level.SEVERE, null, ex);
    }
    agregarMetadatos();
    exitoSubirArchivo = false;
    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.update("formSeleccionarArchivoFormatoA");
    requestContext.update("formMetadatosFormatoA");
    requestContext.update("formArchivoSelecionadoFormatoA");
    requestContext.execute("PF('dlgRegistroFormatoA').hide()");
    metadatosAnteproyectos = new MetadatosAntepoyecto();
    FacesContext.getCurrentInstance().addMessage(null,
            new FacesMessage(FacesMessage.SEVERITY_INFO, "", "La informacin se registro con exito."));
    requestContext.execute("PF('mensajeRegistroExitoso').show()");
}

From source file:com.VanLesh.macsv10.macs.Models.Pdf.java

License:GNU General Public License

public static void maker(Calculation calc) {
    try {//  ww w . j  a v a 2 s .co m
        File pdfFile = new File(Environment.getExternalStorageDirectory().getPath() + "/Report.pdf");
        Document doc = new Document();
        PdfWriter.getInstance(doc, new FileOutputStream(pdfFile));
        doc.open();
        addMetaData(doc, calc);
        addContent(doc, calc);
        doc.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}