Example usage for com.itextpdf.text Document addCreator

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

Introduction

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

Prototype


public boolean addCreator(String creator) 

Source Link

Document

Adds the creator to a Document.

Usage

From source file:edu.ksu.cs.a4vm.bse.reporter.ReporterArchive.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    File1 = jTextField1.getText();
    JFileChooser chooser = new JFileChooser();
    int option = chooser.showOpenDialog(null);
    if (option == JFileChooser.APPROVE_OPTION) {
        if (chooser.getSelectedFile() != null) {
            File3 = chooser.getSelectedFile().getAbsolutePath();
        }//from w  ww .jav a 2s. c  o m
        File file = new File(File1);

        try {
            br1 = new BufferedReader(new FileReader(file));
            b1 = new BufferedReader(new FileReader(file));
        } catch (FileNotFoundException ex) {

        }
        int number_of_rows1 = 0;
        String line = "";
        String cvsSplitBy = ",";
        try {
            while ((line = br1.readLine()) != null) {

                // use comma as separator
                number_of_rows1++;
            }

        } catch (IOException ex) {
            Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex);
        }

        bull1 = new String[number_of_rows1][];
        int k = 0;
        BufferedReader br2 = null;
        try {
            br2 = new BufferedReader(new FileReader(file));
        } catch (FileNotFoundException ex) {
        }
        try {
            while ((line = br2.readLine()) != null) {

                // use comma as separator
                String Bull[] = line.split(",");
                System.out.println(Bull.length);
                bull1[k] = new String[93];
                if (Bull.length < 10) {
                    for (int j = 0; j < 92; j++) {
                        bull1[k][j] = "";
                        //System.out.println(Bull[j]);
                    }
                } else {
                    for (int j = 0; j < Bull.length; j++) {
                        bull1[k][j] = Bull[j];
                        //System.out.println(Bull[j]);
                    }
                }
                k++;
            }
        } catch (IOException ex) {
        }
        Document doc = new Document();
        PdfWriter docWriter = null;

        DecimalFormat df = new DecimalFormat("0.00");

        try {

            //special font sizes
            Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0));
            Font bf12 = new Font(FontFamily.TIMES_ROMAN, 6);
            Font bfBold20 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD);

            //file path

            docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3));

            //document header attributes
            doc.addAuthor("Shubh Chopra");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("Shubh Chopra");
            doc.addTitle("BES");
            doc.setPageSize(PageSize.LETTER.rotate());

            //open document
            doc.open();
            //create a paragraph
            Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n");
            paragraph.setFont(bfBold20);
            paragraph.setAlignment(Element.ALIGN_CENTER);

            Image img = Image.getInstance("VETMED.png");

            img.scaleToFit(300f, 150f);
            doc.add(paragraph);
            PdfPTable table1 = new PdfPTable(2);
            table1.setWidthPercentage(100);
            PdfPCell cell = new PdfPCell(img);
            cell.setBorder(PdfPCell.NO_BORDER);
            table1.addCell(cell);

            String temp1 = "\tOwner: " + bull1[1][78] + " " + bull1[1][79] + "\n\n\tRanch: " + bull1[1][80]
                    + "\n\n\tAddress: " + bull1[1][71] + "\n\n\tCity: " + bull1[1][73] + "\n\n\tState: "
                    + bull1[1][76] + "\tZip: " + bull1[1][77] + "\n\n\tPhone: " + bull1[1][75] + "\n\n";

            table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT));
            doc.add(table1);

            boolean[] checkboxs = { jCheckBox1.isSelected(), jCheckBox2.isSelected(), jCheckBox3.isSelected(),
                    jCheckBox4.isSelected(), jCheckBox5.isSelected(), jCheckBox6.isSelected(),
                    jCheckBox7.isSelected(), jCheckBox8.isSelected(), jCheckBox9.isSelected(),
                    jCheckBox10.isSelected(), jCheckBox11.isSelected(), jCheckBox12.isSelected(),
                    jCheckBox13.isSelected() };
            //specify column widths
            int temp = 0;
            for (int x = 0; x < checkboxs.length; x++) {
                if (checkboxs[x] == true) {
                    temp++;
                }
            }
            float[] columnWidths = new float[temp + 5];
            for (int x = 0; x < columnWidths.length; x++) {
                if (x < 5)
                    columnWidths[x] = 1f;
                else if (jCheckBox1.isSelected() && x == 5)
                    columnWidths[x] = 2f;
                else if (jCheckBox2.isSelected() && jCheckBox3.isSelected() && x == 7)
                    columnWidths[x] = 2f;
                else if (!jCheckBox2.isSelected() && jCheckBox3.isSelected() && x == 6)
                    columnWidths[x] = 2f;
                else if (jCheckBox4.isSelected() && x == columnWidths.length - 2)
                    columnWidths[x] = 2f;
                else if (jCheckBox5.isSelected() && x == columnWidths.length - 1)
                    columnWidths[x] = 2f;
                else
                    columnWidths[x] = 1f;
            }

            //create PDF table with the given widths
            PdfPTable table = new PdfPTable(columnWidths);
            // set table width a percentage of the page width
            table.setWidthPercentage(90f);
            ReporterArchive re;
            re = new ReporterArchive();
            //insert column headings
            re.insertCell(table, "ID-Tag", Element.ALIGN_CENTER, 1, bfBold12);
            re.insertCell(table, "ID-Tatto", Element.ALIGN_CENTER, 1, bfBold12);
            re.insertCell(table, "ID-RFID", Element.ALIGN_CENTER, 1, bfBold12);
            re.insertCell(table, "ID-Brand", Element.ALIGN_CENTER, 1, bfBold12);
            re.insertCell(table, "ID-Other", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox1.isSelected())
                re.insertCell(table, "Age", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox2.isSelected())
                re.insertCell(table, "Scrotal", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox3.isSelected())
                re.insertCell(table, "Motility", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox6.isSelected())
                re.insertCell(table, "Normal", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox7.isSelected())
                re.insertCell(table, "M2", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox8.isSelected())
                re.insertCell(table, "M3", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox9.isSelected())
                re.insertCell(table, "M4", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox10.isSelected())
                re.insertCell(table, "M5", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox11.isSelected())
                re.insertCell(table, "M6", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox12.isSelected())
                re.insertCell(table, "M7", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox13.isSelected())
                re.insertCell(table, "M8", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox4.isSelected())
                re.insertCell(table, "Comments", Element.ALIGN_CENTER, 1, bfBold12);
            if (jCheckBox5.isSelected())
                re.insertCell(table, "Classification", Element.ALIGN_CENTER, 1, bfBold12);

            table.setHeaderRows(1);

            //insert an empty row

            //create section heading by cell merging

            //just some random data to fill 
            for (int x = 1; x < number_of_rows1; x++) {

                re.insertCell(table, bull1[x][7], Element.ALIGN_CENTER, 1, bf12);
                re.insertCell(table, bull1[x][8], Element.ALIGN_CENTER, 1, bf12);
                re.insertCell(table, bull1[x][6], Element.ALIGN_CENTER, 1, bf12);
                re.insertCell(table, bull1[x][2], Element.ALIGN_CENTER, 1, bf12);
                re.insertCell(table, bull1[x][9], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox1.isSelected())
                    re.insertCell(table, bull1[x][0], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox2.isSelected())
                    re.insertCell(table, bull1[x][70], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox3.isSelected())
                    re.insertCell(table, bull1[x][61], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox6.isSelected())
                    re.insertCell(table, bull1[x][43], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox7.isSelected())
                    re.insertCell(table, bull1[x][45], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox8.isSelected())
                    re.insertCell(table, bull1[x][47], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox9.isSelected())
                    re.insertCell(table, bull1[x][49], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox10.isSelected())
                    re.insertCell(table, bull1[x][51], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox11.isSelected())
                    re.insertCell(table, bull1[x][53], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox12.isSelected())
                    re.insertCell(table, bull1[x][55], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox13.isSelected())
                    re.insertCell(table, bull1[x][57], Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox4.isSelected())
                    re.insertCell(table, "", Element.ALIGN_CENTER, 1, bf12);
                if (jCheckBox5.isSelected())
                    re.insertCell(table, bull1[x][35], Element.ALIGN_CENTER, 1, bf12);
            }
            doc.add(table);

        } catch (DocumentException dex) {
            dex.printStackTrace();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            if (doc != null) {
                //close the document
                doc.close();
            }
            if (docWriter != null) {
                //close the writer
                docWriter.close();
            }
        }
        // TODO add your handling code here:
    } //GEN-LAST:event_jButton1ActionPerformed
}

From source file:edu.ucue.jparking.srv.ExportOrdenPagoService.java

private void addMetaData(Document document) {
    document.addTitle("Orden de pago");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Lara-Santos");
    document.addCreator("Lara-Santos");
}

From source file:Ekon.zamestnanecToPDF.java

/**
 * pridani metadat pro prohlizac//from ww w  .  j a  v  a2  s .  co m
 *
 * @param dokument
 */
private static void addMetaData(Document dokument) {
    dokument.addTitle("Vpis zamtnance");
    dokument.addSubject("Vpis,zamstnanec");
    dokument.addKeywords("Zamstnanec,Vpis");
    dokument.addCreator("Ekon");
}

From source file:engine.Pdf.java

public static void addMetaData(Document document) {
    document.addTitle("My first PDF");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Fusion Works");
    document.addCreator("Fusion Works");
}

From source file:es.clinica.veterinaria.facturas.FacturaPdf.java

private void addMetaData(Document document) {
    document.addTitle("Factura N: " + factura.getNumero());
    document.addSubject("Fecha:" + new SimpleDateFormat("yyyy").format(factura.getFecha()));
    document.addKeywords("Facturas PDF");
    document.addAuthor("agustin.alvarez.garcia@gmail.com");
    document.addCreator("agustin.alvarez.garcia@gmail.com");
}

From source file:es.tlc.pdf.writer.PDFWriter.java

private static void addMetaData(Document document) {
    document.addTitle("mesvida");
    document.addSubject("Ficha");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("mesvida");
    document.addCreator("mesvida");
}

From source file:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java

License:Open Source License

private void startExport() {
    final Context context = getContext();

    new AsyncTask<String, Void, String>() {
        protected String doInBackground(String... params) {
            File pdfOutputFile = null;
            try {
                boolean hasAtLeastOne = false;
                /*//from   www  .j  a  v a  2s.c om
                 * get notes
                 */
                List<Note> notesList = DaoNotes.getNotesList(null, false);
                if (notesList.size() == 0) {
                    return NODATA;
                }
                if (isInterrupted)
                    return INTERRUPTED;

                File pdfExportDir = ResourcesManager.getInstance(getActivity()).getMainStorageDir();
                String filename = ResourcesManager.getInstance(getActivity()).getApplicationName()
                        + "_projectexport_" + TimeUtilities.INSTANCE.TIMESTAMPFORMATTER_LOCAL.format(new Date())
                        + ".pdf";
                pdfOutputFile = new File(pdfExportDir, filename);
                if (exportPath != null) {
                    pdfOutputFile = new File(exportPath);
                }

                // TODO export list to pdf
                Document document = new Document();
                document.setMargins(36, 36, 36, 36);
                PdfWriter.getInstance(document, new FileOutputStream(pdfOutputFile));
                document.open();

                document.addTitle("Geopaparazzi PDF Export");
                document.addSubject("Geopaparazzi PDF Export");
                document.addKeywords("geopaparazzi, export, notes");
                document.addAuthor("Geopaparazzi User");
                document.addCreator("Geopaparazzi - http://www.geopaparazzi.eu");

                int index = 1;
                for (Note note : notesList) {
                    processNote(document, note, index++);
                }

                document.close();

                return pdfOutputFile.getAbsolutePath();
            } catch (Exception e) {
                // cleanup as it might be inconsistent
                if (pdfOutputFile != null && pdfOutputFile.exists()) {
                    pdfOutputFile.delete();
                }
                GPLog.error(this, e.getLocalizedMessage(), e);
                e.printStackTrace();
                return ""; //$NON-NLS-1$
            }
        }

        protected void onPostExecute(String response) { // on UI thread!
            progressBar.setVisibility(View.GONE);

            if (response.equals(NODATA)) {
                String msg = context.getString(R.string.no_data_found_in_project_to_export);
                alertDialog.setMessage(msg);
            } else if (response.equals(INTERRUPTED)) {
                alertDialog.setMessage(context.getString(R.string.interrupted_by_user));
            } else if (response.length() > 0) {
                String msg = context.getString(R.string.datasaved) + " " + response;
                alertDialog.setMessage(msg);
            } else {
                String msg = context.getString(R.string.data_nonsaved);
                alertDialog.setMessage(msg);
            }
            if (positiveButton != null)
                positiveButton.setEnabled(true);

        }
    }.execute((String) null);
}

From source file:eu.trentorise.smartcampus.citizenportal.service.PdfCreator.java

private static void addMetaData(Document document) {
    document.addTitle("Graduatoria Provvisoria");
    document.addSubject("Using iText");
    document.addKeywords("Graduatoria, Provvisoria, Edilizia Pubblica");
    document.addAuthor("Comunita Della Vallagarina");
    document.addCreator("Comunita Della Vallagarina");
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Take the patient encounter and build a pdf
 *
 * @param encounterId The id of the encounter to
 * @return The the PDF stream to output to the browser
 *//*  w  w  w. ja v  a  2s  .c o m*/
private byte[] buildPDF(int encounterId) {

    // Get Patient Encounter
    ServiceResponse<PatientEncounterItem> patientEncounterItemServiceResponse = searchService
            .retrievePatientEncounterItemByEncounterId(encounterId);
    if (patientEncounterItemServiceResponse.hasErrors()) {
        throw new RuntimeException();
    }
    PatientEncounterItem patientEncounter = patientEncounterItemServiceResponse.getResponseObject();

    // Get Patient
    ServiceResponse<PatientItem> patientItemServiceResponse = searchService
            .retrievePatientItemByEncounterId(encounterId);
    if (patientItemServiceResponse.hasErrors()) {
        throw new RuntimeException();
    }
    PatientItem patientItem = patientItemServiceResponse.getResponseObject();

    // Get Vitals for Encounter
    ServiceResponse<VitalMultiMap> vitalMultiMapServiceResponse = vitalService
            .retrieveVitalMultiMap(encounterId);
    if (vitalMultiMapServiceResponse.hasErrors()) {
        throw new RuntimeException();
    }
    VitalMultiMap patientVitals = vitalMultiMapServiceResponse.getResponseObject();

    // Get TabFields for Encounter
    ServiceResponse<TabFieldMultiMap> patientEncounterTabFieldResponse = tabService
            .retrieveTabFieldMultiMap(encounterId);
    if (patientEncounterTabFieldResponse.hasErrors()) {
        throw new RuntimeException();
    }
    TabFieldMultiMap tabFieldMultiMap = patientEncounterTabFieldResponse.getResponseObject();

    // Get Prescriptions
    ServiceResponse<List<PrescriptionItem>> prescriptionItemServiceResponse = searchService
            .retrieveDispensedPrescriptionItems(encounterId);
    if (prescriptionItemServiceResponse.hasErrors()) {
        throw new RuntimeException();
    }
    List<PrescriptionItem> prescriptions = prescriptionItemServiceResponse.getResponseObject();

    // Get Problems
    ServiceResponse<List<ProblemItem>> problemItemServiceResponse = encounterService
            .retrieveProblemItems(encounterId);
    if (problemItemServiceResponse.hasErrors()) {
        throw new RuntimeException();
    }
    List<ProblemItem> problems = problemItemServiceResponse.getResponseObject();

    // Will eventually output the PDF -- all 3 lines below are needed
    ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);

    try {

        PdfWriter docWriter = PdfWriter.getInstance(document, pdfStream);
        document.open();

        // PDF Author Info
        document.addAuthor("fEMR");
        document.addCreationDate();
        document.addCreator("fEMR");
        document.addTitle("Patient Report");

        // Add the header to the page
        document.add(createHeaderTable());

        // Add basic patient info
        document.add(createPatientInfoTable(patientItem));

        // Add Encounter Info Table
        document.add(createEncounterInfoTable(patientEncounter));

        // Add Vitals Table
        document.add(createVitalsTable(patientEncounter, patientVitals));

        // Add Assessments Table
        document.add(getAssessments(tabFieldMultiMap, prescriptions, problems));

        // Add Chief Complaints Table
        document.add(getChiefComplaintsTable(tabFieldMultiMap));

        document.close();
        docWriter.close();

    } catch (Exception e) {

        e.printStackTrace();
    }

    return pdfStream.toByteArray();

}

From source file:generadorPDF.generarPDF.java

private static void addMetaData(Document document) {
       document.addTitle("My first PDF");
       document.addSubject("Using iText");
       document.addKeywords("Java, PDF, iText");
       document.addAuthor("Lars Vogel");
       document.addCreator("Lars Vogel");
   }//from  w w  w .  ja v  a 2  s  .c o m