Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfReader$PageRefs


 
  // Where the magic happens | take all the inputs add add them as meta data to the selected PDF
  public void processPDF(String location, String invoiceNo, String date, String accountNo, String amount, String ourRef, String po){
    try {
      // Read the PDF in
      PdfReader reader = new PdfReader(location);

      PdfStamper stamp = new PdfStamper(reader,
        new FileOutputStream(directory+"/Invoice "+invoiceNo+"s.pdf"));
       
      // Custom parse the date - this is brittle but helps the user out as they only have to type ddmmyy rather than dd/mm/yy | Customer request
View Full Code Here


  private void processBytes(
      final String resourceName,
      final int pageNumber)
    throws IOException
  {
    final PdfReader pdfReader = TestResourceUtils.getResourceAsPdfReader(this, resourceName);

    final PdfDictionary pageDictionary = pdfReader.getPageN(pageNumber);

    final PdfDictionary resourceDictionary = pageDictionary.getAsDict(PdfName.RESOURCES);

    final PdfObject contentObject = pageDictionary.get(PdfName.CONTENTS);
    final byte[] contentBytes = readContentBytes(contentObject);
View Full Code Here

    }


    private void checkPdf(final byte[] pdfBytes) throws Exception {

      final PdfReader pdfReader = new PdfReader(pdfBytes);
      final PdfTextExtractor textExtractor = new PdfTextExtractor(pdfReader);
      // Characters from http://unicode.org/charts/PDF/U0000.pdf
      Assert.assertEquals(TEXT1, textExtractor.getTextFromPage(1));
      // Characters from http://unicode.org/charts/PDF/U0080.pdf
      Assert.assertEquals(TEXT2, textExtractor.getTextFromPage(2));
View Full Code Here

      Certificate[] chain = privateEntry.getChain();

      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);
      appearance.setContact(this.request.getContactInfo());
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

    }
   
    @Test
    public void testCoLinnearText() throws Exception{
        byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, false, 0);
        PdfTextExtractor ex = new PdfTextExtractor(new PdfReader(bytes));

        Assert.assertEquals(TEXT1 + TEXT2, ex.getTextFromPage(1));
    }
View Full Code Here

    }
   
    @Test
    public void testCoLinnearTextWithSpace() throws Exception{
        byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, false, 2);
        PdfTextExtractor ex = new PdfTextExtractor(new PdfReader(bytes));

        //saveBytesToFile(bytes, new File("c:/temp/test.pdf"));
       
        Assert.assertEquals(TEXT1 + " " + TEXT2, ex.getTextFromPage(1));
    }
View Full Code Here

    @Test
    public void testCoLinnearTextEndingWithSpaceCharacter() throws Exception{
        // in this case, we shouldn't be inserting an extra space
        TEXT1 = TEXT1 + " ";
        byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, false, 2);
        PdfTextExtractor ex = new PdfTextExtractor(new PdfReader(bytes));

        //saveBytesToFile(bytes, new File("c:/temp/test.pdf"));
       
        Assert.assertEquals(TEXT1 + TEXT2, ex.getTextFromPage(1));
       
View Full Code Here

    }   
    @Test
    public void testUnRotatedText() throws Exception{
       
        byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, true, -20);
        PdfTextExtractor ex = new PdfTextExtractor(new PdfReader(bytes));

        Assert.assertEquals(TEXT1 + "\n" + TEXT2, ex.getTextFromPage(1));
       
    }
View Full Code Here

   
    @Test
    public void testRotatedText() throws Exception{
       
        byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, -90, true, -20);
        PdfTextExtractor ex = new PdfTextExtractor(new PdfReader(bytes));

        Assert.assertEquals(TEXT1 + "\n" + TEXT2, ex.getTextFromPage(1));
       
    }
View Full Code Here

TOP

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

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.