Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfReader


      PdfCopy writer = new PdfCopy(document, outputStream);

      document.open();

      for (InputStream source : sources) {
        PdfReader reader = new PdfReader(source);
        int pageCount = reader.getNumberOfPages();
        for (int i = 1; i <= pageCount; i++) {
          PdfImportedPage page = writer.getImportedPage(reader, i);
          writer.addPage(page);
        }
        reader.close();
      }

      document.close();
      writer.close();
View Full Code Here


  public InputStream[] split(final InputStream source, final int size) {
    try {
      Assert.notNull(source, "source");
      Assert.greaterThan(size, 0, "size");

      PdfReader reader = new PdfReader(source);
      int pageCount = reader.getNumberOfPages();
      List<InputStream> list = new LinkedList<InputStream>();

      Document document = null;
      InputOutputStream outputStream = null;
      PdfCopy writer = null;
      for (int i = 1; i <= pageCount; i++) {
        if ((document == null) || ((i % size) == 0)) {
          if (document != null) {
            document.close();
            writer.close();
            list.add(outputStream.getInputStream());
          }
          document = new Document(reader.getPageSizeWithRotation(1));
          outputStream = new InputOutputStream();
          writer = new PdfCopy(document, outputStream);
        }
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      if (document != null) {
        document.close();
        writer.close();
        list.add(outputStream.getInputStream());
      }

      reader.close();

      return list.toArray(new InputStream[list.size()]);
    } catch (IOException e) {
      throw new PDFException(e);
    } catch (DocumentException e) {
View Full Code Here

  @Override
  public String getText(final InputStream source) {
    try {
      Assert.notNull(source, "source");

      PdfReader reader = new PdfReader(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
      int pageCount = reader.getNumberOfPages();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      PrintWriter writer = new PrintWriter(outputStream);

      for (int i = 1; i <= pageCount; i++) {
        TextExtractionStrategy result = parser.processContent(i, strategy);
        String pageText = result.getResultantText();
        writer.println(pageText);
      }

      reader.close();
      writer.close();

      String text = new String(outputStream.toByteArray());
      return text;
    } catch (IOException e) {
View Full Code Here

      X509Certificate certificate = (X509Certificate) chain[0];

      DigestType digestType = this.getDigestTypeFromSignature(certificate.getSigAlgName());
      Calendar calendar = Calendar.getInstance();

      PdfReader reader = new PdfReader(data);
      PdfStamper stamper = PdfStamper.createSignature(reader, outputStream, PDFSigner.PDF_SIGNATURE_VERSION, null, true);

      PdfSignatureAppearance appearance = stamper.getSignatureAppearance();

      if (this.parameters.getSignatureInfo() != null) {
View Full Code Here

  public Signature[] getSignatures(final byte[] data) {
    try {
      KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
      keystore.load(null, null);

      PdfReader reader = new PdfReader(data);
      AcroFields fields = reader.getAcroFields();
      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
View Full Code Here

      X509Certificate certificate = (X509Certificate) chain[0];

      DigestType digestType = this.getDigestTypeFromSignature(certificate.getSigAlgName());
      Calendar calendar = Calendar.getInstance();

      PdfReader reader = new PdfReader(data);
      PdfStamper stamper = PdfStamper.createSignature(reader, outputStream, PDFSigner.PDF_SIGNATURE_VERSION, null, true);

      PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
      appearance.setCrypto(privateKey, chain, null, PdfSignatureAppearance.SELF_SIGNED);
View Full Code Here

  }

  @Override
  public Signature[] getSignatures(final byte[] data) {
    try {
      PdfReader reader = new PdfReader(data);
      AcroFields fields = reader.getAcroFields();
      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.PdfReader

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.