Example usage for com.itextpdf.text.pdf PdfDictionary put

List of usage examples for com.itextpdf.text.pdf PdfDictionary put

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfDictionary put.

Prototype

public void put(final PdfName key, final PdfObject object) 

Source Link

Document

Associates the specified PdfObject as value with the specified PdfName as key in this map.

Usage

From source file:SignPDF.java

License:Open Source License

public static void main(String args[]) {
    try {/*from w  w w.ja  va2 s .co  m*/

        if (args.length != 1) {
            System.err.println("usage: $0 <pdf-file>");
            System.exit(1);
        }
        src = args[0];
        dest = src + ".temp";

        rcname = System.getenv("SIGNPDFRC");
        if (rcname == null || rcname.length() == 0)
            rcname = System.getenv("HOME") + "/.signpdf";
        else
            System.out.println("using SIGNPDFRC=" + rcname);

        if (!getProperties())
            createDefaultProperties();

        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        ks.load(new FileInputStream(path), keystore_password.toCharArray());
        if (alias == null || alias.length() == 0)
            alias = (String) ks.aliases().nextElement();
        Certificate[] chain = ks.getCertificateChain(alias);
        PrivateKey key = (PrivateKey) ks.getKey(alias, key_password.toCharArray());

        X509Certificate cert = (X509Certificate) ks.getCertificate(alias);
        System.out.println("Signer ID serial     " + cert.getSerialNumber());
        System.out.println("Signer ID version    " + cert.getVersion());
        System.out.println("Signer ID issuer     " + cert.getIssuerDN());
        System.out.println("Signer ID not before " + cert.getNotBefore());
        System.out.println("Signer ID not after  " + cert.getNotAfter());

        // show days valid
        long ticks_now = new Date().getTime();
        long ticks_to = cert.getNotAfter().getTime();

        long ticks_delta = (ticks_to - ticks_now) / TICKS_PER_DAY;
        System.out.println("Certificate will expire in " + ticks_delta + " days.");

        Signature s = Signature.getInstance("SHA1withRSA");
        s.initVerify(ks.getCertificate(alias));

        try {
            cert.checkValidity();
            System.out.println("Validation check passed.");
        } catch (Exception e) {
            System.out.println("Certificate expired or invalid. Abroting.");
            System.exit(1);
        }

        PdfReader reader = new PdfReader(src);
        FileOutputStream os = new FileOutputStream(dest);
        //PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, false);
        PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
        stamper.setEncryption(true, null, null,
                PdfWriter.ALLOW_PRINTING | PdfWriter.ALLOW_SCREENREADERS | PdfWriter.ALLOW_COPY);

        HashMap<String, String> info = reader.getInfo();
        info.put("Creator", "SingPDF " + version);
        stamper.setMoreInfo(info);

        PdfSignatureAppearance appearance = stamper.getSignatureAppearance();

        appearance.setReason(reason);
        appearance.setLocation(location);
        appearance.setContact(contact);
        appearance.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
        appearance.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

        /// ts + ocsp
        PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("adbe.pkcs7.detached"));
        dic.setReason(appearance.getReason());
        dic.setLocation(appearance.getLocation());
        dic.setContact(appearance.getContact());
        dic.setDate(new PdfDate(appearance.getSignDate()));
        appearance.setCryptoDictionary(dic);

        // timestamping + ocsp

        if (tsa_url != null && tsa_url.length() > 0) {

            byte[] ocsp = null;
            TSAClient tsc = null;

            int contentEstimated = 15000;
            HashMap<PdfName, Integer> exc = new HashMap<PdfName, Integer>();
            exc.put(PdfName.CONTENTS, new Integer(contentEstimated * 2 + 2));
            appearance.preClose(exc);

            InputStream data = appearance.getRangeStream();
            MessageDigest mdig = MessageDigest.getInstance("SHA1");

            byte buf[] = new byte[8192];
            int n;
            while ((n = data.read(buf)) > 0) {
                mdig.update(buf, 0, n);
            }

            if (root_cert != null && root_cert.length() > 0) {
                String url = PdfPKCS7.getOCSPURL((X509Certificate) chain[0]);
                CertificateFactory cf = CertificateFactory.getInstance("X509");
                FileInputStream is = new FileInputStream(root_cert);
                X509Certificate root = (X509Certificate) cf.generateCertificate(is);
                ocsp = new OcspClientBouncyCastle().getEncoded((X509Certificate) chain[0], root, url);
            }

            byte hash[] = mdig.digest();
            Calendar cal = Calendar.getInstance();
            PdfPKCS7 sgn = new PdfPKCS7(key, chain, null, "SHA1", null, false);
            byte sh[] = sgn.getAuthenticatedAttributeBytes(hash, cal, ocsp);
            sgn.update(sh, 0, sh.length);

            if (tsa_url != null && tsa_url.length() > 0) {
                tsc = new TSAClientBouncyCastle(tsa_url, tsa_login, tsa_passw);
                byte[] encodedSig = sgn.getEncodedPKCS7(hash, cal, tsc, ocsp);
                if (contentEstimated + 2 < encodedSig.length)
                    throw new Exception("Not enough space");
                byte[] paddedSig = new byte[contentEstimated];
                System.arraycopy(encodedSig, 0, paddedSig, 0, encodedSig.length);
                PdfDictionary dic2 = new PdfDictionary();
                dic2.put(PdfName.CONTENTS, new PdfString(paddedSig).setHexWriting(true));
                appearance.close(dic2);
            }
        }
        // ~timestamping + ocsp 

        File mysrc = new File(src);
        mysrc.delete();
        File mydest = new File(dest);
        mydest.renameTo(mysrc);

        System.exit(0);
    }

    catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:Separator.java

License:Apache License

public static void crop(String inFileName, String outFileName, int split, boolean vert) throws Exception {

    PdfReader reader = new PdfReader(new File(inFileName).getAbsolutePath());
    String PDFName = outFileName.substring(outFileName.lastIndexOf("Folder\\") + 7,
            outFileName.indexOf(".pdf"));
    File fn = new File(scanFolder + PDFName + "\\" + PDFName + "_split_" + split + ".pdf");
    fn.getParentFile().mkdirs();/*from   w w  w .j  av  a 2  s.  c  o m*/

    int count = reader.getNumberOfPages();
    Document doc = new Document();
    PdfCopy copy = new PdfCopy(doc, new FileOutputStream(fn.getAbsolutePath()));
    doc.open();
    if (vert) {
        for (int i = 1; i <= count; i++) {
            reader.getPageN(i).put(PdfName.CROPBOX, new PdfRectangle(PageSize.LETTER));
            copy.addPage(copy.getImportedPage(reader, i));
        }
    } else {
        if (!doubSided) {
            for (int j = 1; j <= count; j++) {
                reader.getPageN(j).put(PdfName.CROPBOX, new PdfRectangle((new Rectangle(0, 180, 792, 792))));
                PdfDictionary pageDict;
                int rot = reader.getPageRotation(j);
                pageDict = reader.getPageN(j);
                pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90));
                copy.addPage(copy.getImportedPage(reader, j));
            }
        } else {
            for (int j = 1; j <= count; j++) {
                reader.getPageN(j).put(PdfName.CROPBOX, new PdfRectangle(new Rectangle(0, 180, 792, 792)));
                PdfDictionary pageDict;
                pageDict = reader.getPageN(j);
                if (j % 2 == 0) { // even
                    pageDict.put(PdfName.ROTATE, new PdfNumber(270));
                } else { // odd
                    pageDict.put(PdfName.ROTATE, new PdfNumber(90));
                }
                copy.addPage(copy.getImportedPage(reader, j));
            }
        }
    }
    doc.close();
}

From source file:at.laborg.briss.CropManager.java

License:Open Source License

private static void cropMultipliedFile(File source, CropJob cropJob)
        throws FileNotFoundException, DocumentException, IOException {

    PdfReader reader = new PdfReader(source.getAbsolutePath());
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(cropJob.getDestinationFile()));
    stamper.setMoreInfo(cropJob.getSourceMetaInfo());

    PdfDictionary pageDict;
    int newPageNumber = 1;
    for (int origPageNumber = 1; origPageNumber <= cropJob.getSourcePageCount(); origPageNumber++) {
        SingleCluster cluster = cropJob.getClusterCollection().getSingleCluster(origPageNumber);

        // if no crop was selected do nothing
        if (cluster.getRatiosList().size() == 0) {
            newPageNumber++;/*ww w .j av a  2  s. c o m*/
            continue;
        }

        for (Float[] ratios : cluster.getRatiosList()) {

            pageDict = reader.getPageN(newPageNumber);

            List<Rectangle> boxes = new ArrayList<Rectangle>();
            boxes.add(reader.getBoxSize(newPageNumber, "media"));
            boxes.add(reader.getBoxSize(newPageNumber, "crop"));
            int rotation = reader.getPageRotation(newPageNumber);

            Rectangle scaledBox = calculateScaledRectangle(boxes, ratios, rotation);

            PdfArray scaleBoxArray = new PdfArray();
            scaleBoxArray.add(new PdfNumber(scaledBox.getLeft()));
            scaleBoxArray.add(new PdfNumber(scaledBox.getBottom()));
            scaleBoxArray.add(new PdfNumber(scaledBox.getRight()));
            scaleBoxArray.add(new PdfNumber(scaledBox.getTop()));

            pageDict.put(PdfName.CROPBOX, scaleBoxArray);
            pageDict.put(PdfName.MEDIABOX, scaleBoxArray);
            // increment the pagenumber
            newPageNumber++;
        }
        int[] range = new int[2];
        range[0] = newPageNumber - 1;
        range[1] = cropJob.getSourcePageCount() + (newPageNumber - origPageNumber);
        SimpleBookmark.shiftPageNumbers(cropJob.getSourceBookmarks(), cluster.getRatiosList().size() - 1,
                range);
    }
    stamper.setOutlines(cropJob.getSourceBookmarks());
    stamper.close();
    reader.close();
}

From source file:at.laborg.briss.utils.DocumentCropper.java

License:Open Source License

private static void cropMultipliedFile(final CropDefinition cropDefinition, final File multipliedDocument,
        final PdfMetaInformation pdfMetaInformation) throws DocumentException, IOException {

    PdfReader reader = new PdfReader(multipliedDocument.getAbsolutePath());

    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(cropDefinition.getDestinationFile()));
    stamper.setMoreInfo(pdfMetaInformation.getSourceMetaInfo());

    PdfDictionary pageDict;
    int newPageNumber = 1;

    for (int sourcePageNumber = 1; sourcePageNumber <= pdfMetaInformation
            .getSourcePageCount(); sourcePageNumber++) {

        List<Float[]> rectangleList = cropDefinition.getRectanglesForPage(sourcePageNumber);

        // if no crop was selected do nothing
        if (rectangleList.isEmpty()) {
            newPageNumber++;//from  ww w  . j  a v a  2  s  .  co  m
            continue;
        }

        for (Float[] ratios : rectangleList) {

            pageDict = reader.getPageN(newPageNumber);

            List<Rectangle> boxes = new ArrayList<Rectangle>();
            boxes.add(reader.getBoxSize(newPageNumber, "media"));
            boxes.add(reader.getBoxSize(newPageNumber, "crop"));
            int rotation = reader.getPageRotation(newPageNumber);

            Rectangle scaledBox = RectangleHandler.calculateScaledRectangle(boxes, ratios, rotation);

            PdfArray scaleBoxArray = createScaledBoxArray(scaledBox);

            pageDict.put(PdfName.CROPBOX, scaleBoxArray);
            pageDict.put(PdfName.MEDIABOX, scaleBoxArray);
            // increment the pagenumber
            newPageNumber++;
        }
        int[] range = new int[2];
        range[0] = newPageNumber - 1;
        range[1] = pdfMetaInformation.getSourcePageCount() + (newPageNumber - sourcePageNumber);
        SimpleBookmark.shiftPageNumbers(pdfMetaInformation.getSourceBookmarks(), rectangleList.size() - 1,
                range);
    }
    stamper.setOutlines(pdfMetaInformation.getSourceBookmarks());
    stamper.close();
    reader.close();
}

From source file:be.roots.taconic.pricingguide.util.iTextUtil.java

License:Open Source License

public static byte[] embedFont(byte[] pdf, String fontFileName, String fontName)
        throws IOException, DocumentException {

    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        // the font file
        RandomAccessFile raf = new RandomAccessFile(fontFileName, "r");
        byte fontfile[] = new byte[(int) raf.length()];
        raf.readFully(fontfile);/* www  .  j  a v  a 2s  .  co  m*/
        raf.close();
        // create a new stream for the font file
        PdfStream stream = new PdfStream(fontfile);
        stream.flateCompress();
        stream.put(PdfName.LENGTH1, new PdfNumber(fontfile.length));
        // create a reader object
        PdfReader reader = new PdfReader(pdf);
        int n = reader.getXrefSize();
        PdfObject object;
        PdfDictionary font;
        PdfStamper stamper = new PdfStamper(reader, baos);
        PdfName fontname = new PdfName(fontName);
        for (int i = 0; i < n; i++) {
            object = reader.getPdfObject(i);
            if (object == null || !object.isDictionary())
                continue;
            font = (PdfDictionary) object;
            if (PdfName.FONTDESCRIPTOR.equals(font.get(PdfName.TYPE1))
                    && fontname.equals(font.get(PdfName.FONTNAME))) {
                PdfIndirectObject objref = stamper.getWriter().addToBody(stream);
                font.put(PdfName.FONTFILE2, objref.getIndirectReference());
            }
        }
        stamper.close();
        reader.close();
        return baos.toByteArray();
    }
}

From source file:com.swisscom.ais.itext.PDF.java

License:Open Source License

/**
 * Add a signature to pdf document/* w  w w .  ja va 2s  .  c  o  m*/
 *
 * @param externalSignature  The extern generated signature
 * @param estimatedSize      Size of external signature
 * @throws Exception 
 */
public void createSignedPdf(@Nonnull byte[] externalSignature, int estimatedSize) throws Exception {
    // Check if source pdf is not protected by a certification
    if (pdfReader.getCertificationLevel() == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED)
        throw new Exception(
                "Could not apply signature because source file contains a certification that does not allow any changes to the document");

    if (Soap._debugMode) {
        System.out.println("\nEstimated SignatureSize: " + estimatedSize);
        System.out.println("Actual    SignatureSize: " + externalSignature.length);
        System.out.println("Remaining Size         : " + (estimatedSize - externalSignature.length));
    }

    if (estimatedSize < externalSignature.length) {
        throw new IOException(
                "\nNot enough space for signature (" + (estimatedSize - externalSignature.length) + " bytes)");
    }

    PdfLiteral pdfLiteral = (PdfLiteral) pdfSignature.get(PdfName.CONTENTS);
    byte[] outc = new byte[(pdfLiteral.getPosLength() - 2) / 2];

    Arrays.fill(outc, (byte) 0);

    System.arraycopy(externalSignature, 0, outc, 0, externalSignature.length);
    PdfDictionary dic2 = new PdfDictionary();
    dic2.put(PdfName.CONTENTS, new PdfString(outc).setHexWriting(true));
    pdfSignatureAppearance.close(dic2);

    // Save to file
    OutputStream outputStream = new FileOutputStream(outputFilePath);
    byteArrayOutputStream.writeTo(outputStream);

    if (Soap._debugMode) {
        System.out.println("\nOK writing signature to " + outputFilePath);
    }

    byteArrayOutputStream.close();
    outputStream.close();
}

From source file:de.rub.dez6a3.jpdfsigner.control.ITextSigner.java

License:Open Source License

public ByteArrayOutputStream doSign(byte[] pdf, Rectangle stampPos, int pageNmbrForStamp) throws IOException,
        DocumentException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
    Certificate[] chain = signCert.toArray(new Certificate[0]);

    PdfReader reader = new PdfReader(pdf);
    ByteArrayOutputStream byteOS = new ByteArrayOutputStream();
    PdfStamper stp = PdfStamper.createSignature(reader, byteOS, '\0', null, true);
    PdfSignatureAppearance sap = stp.getSignatureAppearance();
    if (stampPos != null) {
        sap.setVisibleSignature(//from w w w.  j  a v  a2s  .co m
                new com.itextpdf.text.Rectangle(stampPos.x, stampPos.y, stampPos.width, stampPos.height),
                pageNmbrForStamp, null);
        sap.setRenderingMode(PdfSignatureAppearance.RenderingMode.NAME_AND_DESCRIPTION);
        sap.setAcro6Layers(true);
    }
    //        Siganture Appearance

    PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("adbe.pkcs7.detached"));
    log.info("Creating signature with reason: " + ParamValidator.getInstance().getSignatureReason());
    sap.setReason(ParamValidator.getInstance().getSignatureReason());
    sap.setLocation("Ruhr-Universitt Bochum");
    Image i = Image.getInstance(getClass().getResource("/de/rub/dez6a3/jpdfsigner/resources/images/sign.png"));
    sap.setImage(i);
    sap.setCrypto((PrivateKey) signPrivKey, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
    dic.setReason(ParamValidator.getInstance().getSignatureReason());
    dic.setLocation("Ruhr-Universitt Bochum");
    sap.setCryptoDictionary(dic);
    // preserve some space for the contents
    int contentEstimated = 15000;
    HashMap<PdfName, Integer> exc = new HashMap<PdfName, Integer>();
    exc.put(PdfName.CONTENTS, new Integer(contentEstimated * 2 + 2));
    sap.preClose(exc);
    // make the digest
    InputStream data = sap.getRangeStream();
    MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
    byte buf[] = new byte[8192];
    int n;
    while ((n = data.read(buf)) > 0) {
        messageDigest.update(buf, 0, n);
    }
    byte hash[] = messageDigest.digest();
    Calendar cal = Calendar.getInstance();
    // If we add a time stamp:
    TSAClient tsc = new TSAClientBouncyCastle("http://zeitstempel.dfn.de/");
    // Create the signature

    PdfPKCS7 sgn;
    try {
        sgn = new PdfPKCS7((PrivateKey) signPrivKey, chain, null, "SHA1", null, false);
        byte sh[] = sgn.getAuthenticatedAttributeBytes(hash, cal, null);
        sgn.update(sh, 0, sh.length);
        byte[] encodedSig = sgn.getEncodedPKCS7(hash, cal, tsc, null);

        if (contentEstimated + 2 < encodedSig.length) {
            throw new DocumentException("Not enough space");
        }

        byte[] paddedSig = new byte[contentEstimated];
        System.arraycopy(encodedSig, 0, paddedSig, 0, encodedSig.length);
        // Replace the contents
        PdfDictionary dic2 = new PdfDictionary();
        dic2.put(PdfName.CONTENTS, new PdfString(paddedSig).setHexWriting(true));
        sap.close(dic2);
    } catch (NoSuchProviderException ex) {
        ex.printStackTrace();
    }
    return byteOS;
}

From source file:gov.nih.nci.firebird.service.signing.DigitalSigningServiceBean.java

License:Open Source License

@Override
// This is minimal parameter list for signing.
public void signPdf(InputStream srcPdf, OutputStream destPdf, DigitalSigningAttributes signingAttributes)
        throws DigitalSigningException, IOException {
    try {//  w w w .  j  a v  a2  s  . c  o m
        KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE, BOUNCY_CASTLE_PROVIDER);
        ks.load(signingAttributes.getSigningKeyStore(), signingAttributes.getSigningPassword().toCharArray());
        String alias = ks.aliases().nextElement();
        PrivateKey key = (PrivateKey) ks.getKey(alias, null);
        Certificate[] chain = ks.getCertificateChain(alias);
        // reader and stamper
        PdfReader reader = new PdfReader(srcPdf);
        PdfStamper stamper = PdfStamper.createSignature(reader, destPdf, '\0');
        PdfSignatureAppearance appearance = createPdfSigAppearance(stamper, signingAttributes, chain);
        // create signature dictionary
        PdfSignature dic = createSignatureDictionary(appearance,
                PdfPKCS7.getSubjectFields((X509Certificate) chain[0]).getField("CN"),
                signingAttributes.getSigningReason(), signingAttributes.getSigningLocation());
        appearance.setCryptoDictionary(dic);
        // Reserve space for signature content.
        HashMap<PdfName, Integer> exc = new HashMap<PdfName, Integer>();
        exc.put(PdfName.CONTENTS, Integer.valueOf(CONTENT_SIZE * 2 + 2));
        appearance.preClose(exc);
        // Create hash of content.
        byte[] digest = createMessageDigest(appearance);
        // Creates signed hash.
        byte[] signedHash = generateSignedHash(key, chain, digest);
        // add signature contents.
        PdfDictionary dic2 = new PdfDictionary();
        dic2.put(PdfName.CONTENTS, new PdfString(signedHash).setHexWriting(true));
        appearance.close(dic2);
    } catch (GeneralSecurityException e) {
        throw new DigitalSigningException("Failed signing pdf.", e);
    } catch (DocumentException de) {
        throw new DigitalSigningException("Failed signing pdf.", de);
    }
}

From source file:io.konik.carriage.itext.ITextInvoiceAppender.java

License:Open Source License

private static void attachFile(byte[] attachmentFile, PdfAStamper stamper) throws IOException {
    PdfDictionary embeddedFileParams = new PdfDictionary();
    embeddedFileParams.put(PARAMS, new PdfName(ZF_FILE_NAME));
    embeddedFileParams.put(MODDATE, new PdfDate());

    PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(stamper.getWriter(), null, ZF_FILE_NAME,
            attachmentFile, MIME_TYPE, embeddedFileParams, 0);
    fs.put(AFRELATIONSHIP, Alternative);
    stamper.addFileAttachment(ZF_FILE_NAME, fs);

    PdfArray array = new PdfArray();
    array.add(fs.getReference());//from ww w. j av a  2 s  .c o m
    stamper.getWriter().getExtraCatalog().put(new PdfName("AF"), array);
}

From source file:org.orbisgis.core.renderer.PdfRendererWithAttributes.java

License:Open Source License

@Override
public void beginFeature(long id, DataSource sds) {
    int fieldNameIndex;
    try {//from w  w w. j a v a  2 s. c om
        fieldNameIndex = sds.getFieldIndexByName(fieldName);
    } catch (DriverException ex) {
        Logger.getLogger(PdfRendererWithAttributes.class.getName()).log(Level.SEVERE, null, ex);
        Logger.getLogger("Field name used for attributes does not exist: by default, we use feature + id");
        fieldNameIndex = -1;

    }

    try {
        String attributeName;

        if (fieldNameIndex > -1) {
            attributeName = sds.getFieldValue(id, fieldNameIndex).toString();
        } else {
            attributeName = "feature " + (id + 1);
        }

        PdfStructureElement e = new PdfStructureElement(top, new PdfName(attributeName));
        PdfDictionary userProperties = new PdfDictionary();
        userProperties.put(PdfName.O, PdfName.USERPROPERTIES);
        PdfArray properties = new PdfArray();

        for (int i = 0; i < sds.getFieldCount(); i++) {
            if ((sds.getFieldType(i).getTypeCode() & Type.GEOMETRY) == 0) {
                PdfDictionary property = new PdfDictionary();
                property.put(PdfName.N, new PdfString(sds.getFieldName(i)));
                Value v = sds.getFieldValue(id, i);
                property.put(PdfName.V, new PdfString(v.toString()));
                properties.add(property);
            }
        }

        userProperties.put(PdfName.P, properties);
        e.put(PdfName.A, userProperties);

        pTemp = cb.createTemplate(width, height);
        cb.beginMarkedContentSequence(e);

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