Announcement

Collapse
No announcement yet.

count number of pages in pdf

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • count number of pages in pdf

    Hi Guys,

    I'm trying to encode and decode the pdf file to identify the differences in the output files. While doing so, i like to count the number of pages available in the pdf, which would be of great help from user perspective.

    I can encode and decode the pdf file but i couldn't identify a way to count number of pages in the pdf. can u guys help me on this? mirth3.3.1

    Mirth Interface Engineer
    AWS DevOps

  • #2
    Maybe this will help you:

    http://stackoverflow.com/questions/4...-in-a-pdf-file

    Comment


    • #3
      couldn't find any changes

      Hi rauchj,

      I tried the link and got into http://pdfbox.apache.org/download.html to use pdfbox apache and got apache pdfbox jar file and placed them in custom-lib folder of mirth but couldn't find those code working, neither i noticed the inclusion of additional in-built functions inside mirth.
      Is this a rightway? Am I doing it correctly? .or am I going wron somewhere?

      Mirth Interface Engineer
      AWS DevOps

      Comment


      • #4
        what mirth version do you use?

        have a look here: http://www.mirthcorp.com/community/w...+Mirth+Connect

        Comment


        • #5
          Was recently looking how to do this and couldn't find much on the forums so here's a snippet that worked using a File Reader

          Code:
          var srcFile = sourceMap.get('originalFilename');
          var srcDir = sourceMap.get('fileDirectory');
          
          var fileConts = FileUtil.readBytes(srcDir +'/' +srcFile);
          var file = new Packages.com.itextpdf.text.pdf.PdfReader(fileConts);
          var pageNum = file.getNumberOfPages();
          pageNum = pageNum.toString().substring(0,1);
          file.close();

          Comment

          Working...
          X