Package com.itextpdf.text

Examples of com.itextpdf.text.ExceptionConverter


                    baseFont.writeFont(writer, indirectReference, new Object[]{longTag, Boolean.valueOf(subset)});
                    break;
            }
        }
        catch(Exception e) {
            throw new ExceptionConverter(e);
        }
    }
View Full Code Here


        if (tagged) {
            try {
                getStructureTreeRoot().buildTree();
            }
            catch (Exception e) {
                throw new ExceptionConverter(e);
            }
            catalog.put(PdfName.STRUCTTREEROOT, structureTreeRoot.getReference());
            PdfDictionary mi = new PdfDictionary();
            mi.put(PdfName.MARKED, PdfBoolean.PDFTRUE);
            if (userProperties)
View Full Code Here

        PdfIndirectObject object;
        try {
            object = addToBody(contents);
        }
        catch(IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
        page.add(object.getIndirectReference());
        // [U5]
        if (group != null) {
            page.put(PdfName.GROUP, group);
View Full Code Here

  public PdfEncryption() {
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
    publicKeyHandler = new PdfPublicKeySecurityHandler();
  }
View Full Code Here

                permsp[11] = (byte)'b';
                ac = new AESCipherCBCnoPad(true, key);
                perms = ac.processBlock(permsp, 0, permsp.length);
            }
            catch (Exception ex) {
                throw new ExceptionConverter(ex);
            }
        }
        else {
            // PDF reference 3.5.2 Standard Security Handler, Algorithm 3.3-1
            // If there is no owner password, use the user password instead.
View Full Code Here

        }
        catch (BadPasswordException ex) {
            throw ex;
        }
        catch (Exception ex) {
            throw new ExceptionConverter(ex);
        }
    }
View Full Code Here

  public static byte[] createDocumentId() {
    MessageDigest md5;
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
    long time = System.currentTimeMillis();
    long mem = Runtime.getRuntime().freeMemory();
    String s = time + "+" + mem + "+" + (seq++);
    return md5.digest(s.getBytes());
View Full Code Here

      dic.put(PdfName.R, new PdfNumber(revision));

      try {
        recipients = publicKeyHandler.getEncodedRecipients();
      } catch (Exception f) {
        throw new ExceptionConverter(f);
      }

      if (revision == STANDARD_ENCRYPTION_40) {
        dic.put(PdfName.V, new PdfNumber(1));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S4);
        dic.put(PdfName.RECIPIENTS, recipients);
      } else if (revision == STANDARD_ENCRYPTION_128 && encryptMetadata) {
        dic.put(PdfName.V, new PdfNumber(2));
        dic.put(PdfName.LENGTH, new PdfNumber(128));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S4);
        dic.put(PdfName.RECIPIENTS, recipients);
      } else {
        dic.put(PdfName.R, new PdfNumber(AES_128));
        dic.put(PdfName.V, new PdfNumber(4));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S5);

        PdfDictionary stdcf = new PdfDictionary();
        stdcf.put(PdfName.RECIPIENTS, recipients);
        if (!encryptMetadata)
          stdcf.put(PdfName.ENCRYPTMETADATA, PdfBoolean.PDFFALSE);

        if (revision == AES_128)
          stdcf.put(PdfName.CFM, PdfName.AESV2);
        else
          stdcf.put(PdfName.CFM, PdfName.V2);
        PdfDictionary cf = new PdfDictionary();
        cf.put(PdfName.DEFAULTCRYPTFILTER, stdcf);
        dic.put(PdfName.CF, cf);
                if (embeddedFilesOnly) {
          dic.put(PdfName.EFF, PdfName.DEFAULTCRYPTFILTER);
          dic.put(PdfName.STRF, PdfName.IDENTITY);
          dic.put(PdfName.STMF, PdfName.IDENTITY);
        }
        else {
          dic.put(PdfName.STRF, PdfName.DEFAULTCRYPTFILTER);
          dic.put(PdfName.STMF, PdfName.DEFAULTCRYPTFILTER);
        }
      }

      MessageDigest md = null;
      byte[] encodedRecipient = null;

      try {
        md = MessageDigest.getInstance("SHA-1");
        md.update(publicKeyHandler.getSeed());
        for (int i = 0; i < publicKeyHandler.getRecipientsSize(); i++) {
          encodedRecipient = publicKeyHandler.getEncodedRecipient(i);
          md.update(encodedRecipient);
        }
        if (!encryptMetadata)
          md.update(new byte[] { (byte) 255, (byte) 255, (byte) 255,
              (byte) 255 });
      } catch (Exception f) {
        throw new ExceptionConverter(f);
      }

      byte[] mdResult = md.digest();

      setupByEncryptionKey(mdResult, keyLength);
View Full Code Here

      OutputStreamEncryption os2 = getEncryptionStream(ba);
      os2.write(b);
      os2.finish();
      return ba.toByteArray();
    } catch (IOException ex) {
      throw new ExceptionConverter(ex);
    }
  }
View Full Code Here

      b2 = dec.finish();
      if (b2 != null)
        ba.write(b2);
      return ba.toByteArray();
    } catch (IOException ex) {
      throw new ExceptionConverter(ex);
    }
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.ExceptionConverter

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