Example usage for com.itextpdf.text.pdf PdfPCell setBorderWidth

List of usage examples for com.itextpdf.text.pdf PdfPCell setBorderWidth

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setBorderWidth.

Prototype

public void setBorderWidth(final float borderWidth) 

Source Link

Document

Sets the borderwidth of the table.

Usage

From source file:GUI_StafKlinik.Panel_Penggajian.java

private PdfPTable createTableLaporan(Penggajian p) {
    PdfPTable tabel = new PdfPTable(2);
    PdfPCell cell;

    cell = new PdfPCell(new Phrase(("Nama Pegawai"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);//from  w  w  w . j  a  va 2s.c o m
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("" + p.getNamaPegawai()), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("ID Pegawai"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("" + p.getIdPegawai()), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Alamat"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase((""), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Telepon"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase((""), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Jabatan"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase((""), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Gaji Pokok"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("" + p.getGajiPokok()), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Gaji Tambahan"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("" + p.getGajiTambahan()), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("Total Gaji"), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    cell = new PdfPCell(new Phrase(("" + p.getTotalGaji()), font2));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(1);
    cell.setBorderColor(BaseColor.WHITE);
    tabel.addCell(cell);

    return tabel;
}

From source file:jdbreport.model.io.pdf.itext5.PdfWriter.java

License:Apache License

private void assignBorders(CellStyle style, PdfPCell pdfCell) {
    pdfCell.setBorderWidth(0);
    Border border = style.getBorders(Border.LINE_LEFT);
    if (border != null) {
        pdfCell.setBorderWidthLeft(border.getLineWidth());
        pdfCell.setBorderColorLeft(new BaseColor(border.getColor().getRGB()));
    }/*from   ww  w. j  a va2  s  .  c  om*/
    border = style.getBorders(Border.LINE_RIGHT);
    if (border != null) {
        pdfCell.setBorderWidthRight(border.getLineWidth());
        pdfCell.setBorderColorRight(new BaseColor(border.getColor().getRGB()));
    }
    border = style.getBorders(Border.LINE_TOP);
    if (border != null) {
        pdfCell.setBorderWidthTop(border.getLineWidth());
        pdfCell.setBorderColorTop(new BaseColor(border.getColor().getRGB()));
    }
    border = style.getBorders(Border.LINE_BOTTOM);
    if (border != null) {
        pdfCell.setBorderWidthBottom(border.getLineWidth());
        pdfCell.setBorderColorBottom(new BaseColor(border.getColor().getRGB()));
    }
}

From source file:net.digitstar.vanadio.helpers.PdfHelper.java

License:Apache License

public static PdfPCell newCell(CellStyle style) {
    PdfPCell cell = new PdfPCell();
    if (style != null) {
        if (style.getNestedTable() != null) {
            cell = new PdfPCell(style.getNestedTable());
            style.setNestedTable(null);/*from www . j a v a 2 s.  c o  m*/
        } else if (style.getImage() != null) {
            cell = new PdfPCell(style.getImage(), style.isFitImage());
            style.setImage(null);
        } else if (style.getText() != null) {
            cell = new PdfPCell(style.getText());
            style.setText((String) null);
        }

        cell.setColspan(style.getColspan());
        cell.setRowspan(style.getRowspan());

        cell.setMinimumHeight(style.getMinimumHeight());
        cell.setFixedHeight(style.getFixedHeight());

        cell.setNoWrap(style.isNoWrap());

        cell.setRotation(style.getRotation().getValue());

        style = Alignment.assign(style);

        cell.setHorizontalAlignment(style.getHorizAlign().getValue());
        cell.setVerticalAlignment(style.getVertAlign().getValue());

        cell.setUseVariableBorders(style.isUseVariableBorders());
        cell.setUseBorderPadding(style.isUseBorderPadding());

        if (!style.getBorderWidth().isAllSideEqual()) {
            cell.setBorderWidthBottom(style.getBorderWidth().getBottom());
            cell.setBorderWidthLeft(style.getBorderWidth().getLeft());
            cell.setBorderWidthRight(style.getBorderWidth().getRight());
            cell.setBorderWidthTop(style.getBorderWidth().getTop());
        } else {
            cell.setBorderWidth(style.getBorderWidth().getValue());
        }

        cell.setPaddingBottom(style.getPadding().getBottom());
        cell.setPaddingLeft(style.getPadding().getLeft());
        cell.setPaddingRight(style.getPadding().getRight());
        cell.setPaddingTop(style.getPadding().getTop());

        cell.setBorderColorBottom(style.getBorderColor().getBottom());
        cell.setBorderColorLeft(style.getBorderColor().getLeft());
        cell.setBorderColorRight(style.getBorderColor().getRight());
        cell.setBorderColorTop(style.getBorderColor().getTop());

        cell.setBorder(style.getBorder().getValue());

        cell.setBackgroundColor(style.getBackgroundColor());
        if (style.getGreyFill() >= 0) {
            cell.setGrayFill(style.getGreyFill());
        }
    }
    return cell;
}

From source file:net.pflaeging.PortableSigner.PDFSigner.java

License:Open Source License

/** Creates a new instance of DoSignPDF */
public void doSignPDF(String pdfInputFileName, String pdfOutputFileName, String pkcs12FileName, String password,
        Boolean signText, String signLanguage, String sigLogo, Boolean finalize, String sigComment,
        String signReason, String signLocation, Boolean noExtraPage, float verticalPos, float leftMargin,
        float rightMargin, Boolean signLastPage, byte[] ownerPassword) throws PDFSignerException {
    try {// ww w.  j  ava 2  s  .co m
        //System.out.println("-> DoSignPDF <-");
        //System.out.println("Eingabedatei: " + pdfInputFileName);
        //System.out.println("Ausgabedatei: " + pdfOutputFileName);
        //System.out.println("Signaturdatei: " + pkcs12FileName);
        //System.out.println("Signaturblock?: " + signText);
        //System.out.println("Sprache der Blocks: " + signLanguage);
        //System.out.println("Signaturlogo: " + sigLogo);
        System.err.println("Position V:" + verticalPos + " L:" + leftMargin + " R:" + rightMargin);
        Rectangle signatureBlock;

        java.security.Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 2);

        pkcs12 = new GetPKCS12(pkcs12FileName, password);

        PdfReader reader = null;
        try {
            //                System.out.println("Password:" + ownerPassword.toString());
            if (ownerPassword == null)
                reader = new PdfReader(pdfInputFileName);
            else
                reader = new PdfReader(pdfInputFileName, ownerPassword);
        } catch (IOException e) {

            /* MODIFY BY: Denis Torresan
             Main.setResult(
                java.util.ResourceBundle.getBundle(
                "net/pflaeging/PortableSigner/i18n").getString(
                "CouldNotBeOpened"),
                true,
                e.getLocalizedMessage());
             */

            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n")
                    .getString("CouldNotBeOpened"), true, e.getLocalizedMessage());
        }
        FileOutputStream fout = null;
        try {
            fout = new FileOutputStream(pdfOutputFileName);
        } catch (FileNotFoundException e) {

            /* MODIFY BY: Denis Torresan
             Main.setResult(
                java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("CouldNotBeWritten"),
                true,
                e.getLocalizedMessage());
             */

            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n")
                    .getString("CouldNotBeWritten"), true, e.getLocalizedMessage());

        }
        PdfStamper stp = null;
        try {
            Date datum = new Date(System.currentTimeMillis());

            int pages = reader.getNumberOfPages();

            Rectangle size = reader.getPageSize(pages);
            stp = PdfStamper.createSignature(reader, fout, '\0', null, true);
            HashMap<String, String> pdfInfo = reader.getInfo();
            // thanks to Markus Feisst
            String pdfInfoProducer = "";

            if (pdfInfo.get("Producer") != null) {
                pdfInfoProducer = pdfInfo.get("Producer").toString();
                pdfInfoProducer = pdfInfoProducer + " (signed with PortableSigner " + Version.release + ")";
            } else {
                pdfInfoProducer = "Unknown Producer (signed with PortableSigner " + Version.release + ")";
            }
            pdfInfo.put("Producer", pdfInfoProducer);
            //System.err.print("++ Producer:" + pdfInfo.get("Producer").toString());
            stp.setMoreInfo(pdfInfo);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XmpWriter xmp = new XmpWriter(baos, pdfInfo);
            xmp.close();
            stp.setXmpMetadata(baos.toByteArray());
            if (signText) {
                String greet, signator, datestr, ca, serial, special, note, urn, urnvalue;
                int specialcount = 0;
                int sigpage;
                int rightMarginPT, leftMarginPT;
                float verticalPositionPT;
                ResourceBundle block = ResourceBundle
                        .getBundle("net/pflaeging/PortableSigner/Signatureblock_" + signLanguage);
                greet = block.getString("greeting");
                signator = block.getString("signator");
                datestr = block.getString("date");
                ca = block.getString("issuer");
                serial = block.getString("serial");
                special = block.getString("special");
                note = block.getString("note");
                urn = block.getString("urn");
                urnvalue = block.getString("urnvalue");

                //sigcomment = block.getString(signLanguage + "-comment");
                // upper y
                float topy = size.getTop();
                System.err.println("Top: " + topy * ptToCm);
                // right x
                float rightx = size.getRight();
                System.err.println("Right: " + rightx * ptToCm);
                if (!noExtraPage) {
                    sigpage = pages + 1;
                    stp.insertPage(sigpage, size);
                    // 30pt left, 30pt right, 20pt from top
                    rightMarginPT = 30;
                    leftMarginPT = 30;
                    verticalPositionPT = topy - 20;
                } else {
                    if (signLastPage) {
                        sigpage = pages;
                    } else {
                        sigpage = 1;
                    }
                    System.err.println("Page: " + sigpage);
                    rightMarginPT = Math.round(rightMargin / ptToCm);
                    leftMarginPT = Math.round(leftMargin / ptToCm);
                    verticalPositionPT = topy - Math.round(verticalPos / ptToCm);
                }
                if (!GetPKCS12.atEgovOID.equals("")) {
                    specialcount = 1;
                }
                PdfContentByte content = stp.getOverContent(sigpage);

                float[] cellsize = new float[2];
                cellsize[0] = 100f;
                // rightx = width of page
                // 60 = 2x30 margins
                // cellsize[0] = description row
                // cellsize[1] = 0
                // 70 = logo width
                cellsize[1] = rightx - rightMarginPT - leftMarginPT - cellsize[0] - cellsize[1] - 70;

                // Pagetable = Greeting, signatureblock, comment
                // sigpagetable = outer table
                //      consist: greetingcell, signatureblock , commentcell
                PdfPTable signatureBlockCompleteTable = new PdfPTable(2);
                PdfPTable signatureTextTable = new PdfPTable(2);
                PdfPCell signatureBlockHeadingCell = new PdfPCell(
                        new Paragraph(new Chunk(greet, new Font(Font.FontFamily.HELVETICA, 12))));
                signatureBlockHeadingCell.setPaddingBottom(5);
                signatureBlockHeadingCell.setColspan(2);
                signatureBlockHeadingCell.setBorderWidth(0f);
                signatureBlockCompleteTable.addCell(signatureBlockHeadingCell);

                // inner table start
                // Line 1
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(signator, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(GetPKCS12.subject, new Font(Font.FontFamily.COURIER, 10))));
                // Line 2
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(datestr, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(datum.toString(), new Font(Font.FontFamily.COURIER, 10))));
                // Line 3
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(ca, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(GetPKCS12.issuer, new Font(Font.FontFamily.COURIER, 10))));
                // Line 4
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(serial, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(
                        new Chunk(GetPKCS12.serial.toString(), new Font(Font.FontFamily.COURIER, 10))));
                // Line 5
                if (specialcount == 1) {
                    signatureTextTable.addCell(new Paragraph(
                            new Chunk(special, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                    signatureTextTable.addCell(new Paragraph(
                            new Chunk(GetPKCS12.atEgovOID, new Font(Font.FontFamily.COURIER, 10))));
                }
                signatureTextTable.addCell(
                        new Paragraph(new Chunk(urn, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable
                        .addCell(new Paragraph(new Chunk(urnvalue, new Font(Font.FontFamily.COURIER, 10))));
                signatureTextTable.setTotalWidth(cellsize);
                System.err.println(
                        "signatureTextTable Width: " + cellsize[0] * ptToCm + " " + cellsize[1] * ptToCm);
                // inner table end

                signatureBlockCompleteTable.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                Image logo;
                //                     System.out.println("Logo:" + sigLogo + ":");
                if (sigLogo == null || "".equals(sigLogo)) {
                    logo = Image.getInstance(
                            getClass().getResource("/net/pflaeging/PortableSigner/SignatureLogo.png"));
                } else {
                    logo = Image.getInstance(sigLogo);
                }

                PdfPCell logocell = new PdfPCell();
                logocell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                logocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                logocell.setImage(logo);
                signatureBlockCompleteTable.addCell(logocell);
                PdfPCell incell = new PdfPCell(signatureTextTable);
                incell.setBorderWidth(0f);
                signatureBlockCompleteTable.addCell(incell);
                PdfPCell commentcell = new PdfPCell(
                        new Paragraph(new Chunk(sigComment, new Font(Font.FontFamily.HELVETICA, 10))));
                PdfPCell notecell = new PdfPCell(
                        new Paragraph(new Chunk(note, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                //commentcell.setPaddingTop(10);
                //commentcell.setColspan(2);
                // commentcell.setBorderWidth(0f);
                if (!sigComment.equals("")) {
                    signatureBlockCompleteTable.addCell(notecell);
                    signatureBlockCompleteTable.addCell(commentcell);
                }
                float[] cells = { 70, cellsize[0] + cellsize[1] };
                signatureBlockCompleteTable.setTotalWidth(cells);
                System.err.println(
                        "signatureBlockCompleteTable Width: " + cells[0] * ptToCm + " " + cells[1] * ptToCm);
                signatureBlockCompleteTable.writeSelectedRows(0, 4 + specialcount, leftMarginPT,
                        verticalPositionPT, content);
                System.err.println(
                        "signatureBlockCompleteTable Position " + 30 * ptToCm + " " + (topy - 20) * ptToCm);
                signatureBlock = new Rectangle(30 + signatureBlockCompleteTable.getTotalWidth() - 20,
                        topy - 20 - 20, 30 + signatureBlockCompleteTable.getTotalWidth(), topy - 20);
                //                    //////
                //                    AcroFields af = reader.getAcroFields();
                //                    ArrayList names = af.getSignatureNames();
                //                    for (int k = 0; k < names.size(); ++k) {
                //                        String name = (String) names.get(k);
                //                        System.out.println("Signature name: " + name);
                //                        System.out.println("\tSignature covers whole document: " + af.signatureCoversWholeDocument(name));
                //                        System.out.println("\tDocument revision: " + af.getRevision(name) + " of " + af.getTotalRevisions());
                //                        PdfPKCS7 pk = af.verifySignature(name);
                //                        X509Certificate tempsigner = pk.getSigningCertificate();
                //                        Calendar cal = pk.getSignDate();
                //                        Certificate pkc[] = pk.getCertificates();
                //                        java.util.ResourceBundle tempoid =
                //                                java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/SpecialOID");
                //                        String tmpEgovOID = "";
                //
                //                        for (Enumeration<String> o = tempoid.getKeys(); o.hasMoreElements();) {
                //                            String element = o.nextElement();
                //                            // System.out.println(element + ":" + oid.getString(element));
                //                            if (tempsigner.getNonCriticalExtensionOIDs().contains(element)) {
                //                                if (!tmpEgovOID.equals("")) {
                //                                    tmpEgovOID += ", ";
                //                                }
                //                                tmpEgovOID += tempoid.getString(element) + " (OID=" + element + ")";
                //                            }
                //                        }
                //                        //System.out.println("\tSigniert von: " + PdfPKCS7.getSubjectFields(pk.getSigningCertificate()));
                //                        System.out.println("\tSigniert von: " + tempsigner.getSubjectX500Principal().toString());
                //                        System.out.println("\tDatum: " + cal.getTime().toString());
                //                        System.out.println("\tAusgestellt von: " + tempsigner.getIssuerX500Principal().toString());
                //                        System.out.println("\tSeriennummer: " + tempsigner.getSerialNumber());
                //                        if (!tmpEgovOID.equals("")) {
                //                            System.out.println("\tVerwaltungseigenschaft: " + tmpEgovOID);
                //                        }
                //                        System.out.println("\n");
                //                        System.out.println("\tDocument modified: " + !pk.verify());
                ////                Object fails[] = PdfPKCS7.verifyCertificates(pkc, kall, null, cal);
                ////                if (fails == null) {
                ////                    System.out.println("\tCertificates verified against the KeyStore");
                ////                } else {
                ////                    System.out.println("\tCertificate failed: " + fails[1]);
                ////                }
                //                    }
                //
                //                //////
            } else {
                signatureBlock = new Rectangle(0, 0, 0, 0); // fake definition
            }
            PdfSignatureAppearance sap = stp.getSignatureAppearance();
            //                sap.setCrypto(GetPKCS12.privateKey, GetPKCS12.certificateChain, null,
            //                        PdfSignatureAppearance.WINCER_SIGNED );
            sap.setCrypto(GetPKCS12.privateKey, GetPKCS12.certificateChain, null, null);
            sap.setReason(signReason);
            sap.setLocation(signLocation);
            //                if (signText) {
            //                    sap.setVisibleSignature(signatureBlock,
            //                            pages + 1, "PortableSigner");
            //                }
            if (finalize) {
                sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
            } else {
                sap.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
            }
            stp.close();

            /* MODIFY BY: Denis Torresan
            Main.setResult(
              java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("IsGeneratedAndSigned"),
              false,
              "");
                */

        } catch (Exception e) {

            /* MODIFY BY: Denis Torresan
             Main.setResult(
                java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("ErrorWhileSigningFile"),
                true,
                e.getLocalizedMessage());
             */

            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n")
                    .getString("ErrorWhileSigningFile"), true, e.getLocalizedMessage());

        }
    } catch (KeyStoreException kse) {

        /* MODIFY BY: Denis Torresan
         Main.setResult(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("ErrorCreatingKeystore"),
            true, kse.getLocalizedMessage());
         */

        throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n")
                .getString("ErrorCreatingKeystore"), true, kse.getLocalizedMessage());

    }
}

From source file:org.dspace.disseminate.CitationDocument.java

/**
 * Takes a DSpace {@link Bitstream} and uses its associated METADATA to
 * create a cover page./* w ww. j a  v a2 s . c o  m*/
 *
 * @param cDoc The cover page document to add cited information to.
 * @param writer
 * @param cMeta
 *            METADATA retrieved from the parent collection.
 * @throws IOException
 * @throws DocumentException
 */
private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException {
    cDoc.open();
    writer.setCompressionLevel(0);

    Item item = cMeta.getItem();

    //Set up some fonts
    Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK);
    Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK);
    Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK);
    Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK);
    Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK);
    Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK);

    // 1 - Header:
    //  University Name
    //  Repository Name                                                        repository.url
    Paragraph university = new Paragraph("The Ohio State University", helv11_bold);
    cDoc.add(university);

    PdfPTable repositoryTable = new PdfPTable(2);
    repositoryTable.setWidthPercentage(100);

    Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold);
    PdfPCell nameCell = new PdfPCell();
    nameCell.setBorderWidth(0);
    nameCell.addElement(repositoryName);

    Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold);
    repositoryURL.setAnchor("http://kb.osu.edu");

    PdfPCell urlCell = new PdfPCell();
    urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    urlCell.setBorderWidth(0);
    urlCell.addElement(repositoryURL);

    repositoryTable.addCell(nameCell);
    repositoryTable.addCell(urlCell);

    repositoryTable.setSpacingAfter(5);

    cDoc.add(repositoryTable);

    // Line Separator
    LineSeparator lineSeparator = new LineSeparator();
    cDoc.add(lineSeparator);

    // 2 - Bread Crumbs
    // Community Name                                                          Collection Name
    PdfPTable breadcrumbTable = new PdfPTable(2);
    breadcrumbTable.setWidthPercentage(100);

    Chunk communityName = new Chunk(getOwningCommunity(item), helv9);
    PdfPCell commCell = new PdfPCell();
    commCell.setBorderWidth(0);
    commCell.addElement(communityName);

    Chunk collectionName = new Chunk(getOwningCollection(item), helv9);
    PdfPCell collCell = new PdfPCell();
    collCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    collCell.setBorderWidth(0);
    collCell.addElement(collectionName);

    breadcrumbTable.addCell(commCell);
    breadcrumbTable.addCell(collCell);

    breadcrumbTable.setSpacingBefore(5);
    breadcrumbTable.setSpacingAfter(5);

    cDoc.add(breadcrumbTable);

    // Line Separator
    cDoc.add(lineSeparator);

    // 3 - Metadata
    // date.issued
    // dc.title
    // dc.creator; dc.creator
    Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12);
    dateIssued.setSpacingBefore(20);
    cDoc.add(dateIssued);

    Paragraph title = new Paragraph(item.getName(), helv26);
    title.setSpacingBefore(15);
    cDoc.add(title);

    Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16);
    creators.setSpacingBefore(30);
    creators.setSpacingAfter(20);
    cDoc.add(creators);

    // Line Separator
    cDoc.add(lineSeparator);

    // 4 - Citation
    // dc.identifier.citation
    // dc.identifier.uri
    Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12);

    Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12);
    identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri"));

    Paragraph identifier = new Paragraph();
    identifier.add(identifierChunk);

    cDoc.add(citation);
    cDoc.add(identifier);

    // 5 - License
    // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository
    Paragraph license = new Paragraph(
            "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository",
            helv12_italic);
    license.setSpacingBefore(10);
    cDoc.add(license);

    cDoc.close();
}

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildHeaderNameLine(String schuelername, Font headerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Name", headerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(schuelername, headerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);/*w w w .j a  v  a2  s .  c  o  m*/
    nameCell.setColspan(5);

    PdfPTable table = prebuildHeaderTable();
    table.addCell(labelCell);
    table.addCell(nameCell);

    return table;
}

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildHeaderKlassendatenLine(LebData lebData, Font headerFont) throws DocumentException {
    PdfPCell leftLabelCell = new PdfPCell(new Phrase("Klasse", headerFont));
    leftLabelCell.setBorder(Rectangle.BOTTOM);
    leftLabelCell.setBorderWidth(1f);

    PdfPCell leftValueCell = new PdfPCell(new Phrase(lebData.getKlassenname(), headerFont));
    leftValueCell.setBorder(Rectangle.BOTTOM);
    leftValueCell.setBorderWidth(1f);/*w  w w. j a v a 2 s .c o  m*/

    PdfPCell centerLabelCell = new PdfPCell(new Phrase("Schuljahr", headerFont));
    centerLabelCell.setBorder(Rectangle.BOTTOM);
    centerLabelCell.setBorderWidth(1f);

    PdfPCell centerValueCell = new PdfPCell(new Phrase(lebData.getSchuljahr(), headerFont));
    centerValueCell.setBorder(Rectangle.BOTTOM);
    centerValueCell.setBorderWidth(1f);

    PdfPCell rightLabelCell = new PdfPCell(new Phrase("Schulhalbjahr", headerFont));
    rightLabelCell.setBorder(Rectangle.BOTTOM);
    rightLabelCell.setBorderWidth(1f);

    PdfPCell rightValueCell = new PdfPCell(
            new Phrase(lebData.getSchulhalbjahr().getId().toString(), headerFont));
    rightValueCell.setBorder(Rectangle.BOTTOM);
    rightValueCell.setBorderWidth(1f);

    PdfPTable table = prebuildHeaderTable();
    table.addCell(leftLabelCell);
    table.addCell(leftValueCell);
    table.addCell(centerLabelCell);
    table.addCell(centerValueCell);
    table.addCell(rightLabelCell);
    table.addCell(rightValueCell);
    return table;
}

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont)
        throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);/* w  ww .  j a  v a 2s  . co m*/

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] { 0.3f, 0.7f });
    return table;
}

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);//from w w  w.  j a  v  a2s. c om

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] { 0.3f, 0.7f });
    return table;
}

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setBorderWidth(1f);

    PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setBorderWidth(1f);/*from  w ww .  j av  a  2  s.  c o  m*/
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(3);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] { 0.3f, 0.3f, 0.3f });
    return table;
}