Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get PDF file Page count while uploading PDF document

jhon_jhon
Explorer
0 Likes
2,878

Hi

My Requirement is to Count PDF Pages while uploading document , How to approach to achieve this requirement.


I have tried a lot but didn't get it , Help would be appreciated.


Thanks

Hi

My Requirement is to Count PDF Pages while uploading document , How to approach to achieve this requirement.


I have tried a lot but didn't get it , Help would be appreciated.


Thanks

6 REPLIES 6
Read only

former_member235395
Contributor
0 Likes
1,935

Hi Jhon,

Are you working with Smartforms and OTF? If so, check this thread: Page counter over multiple Smartforms | SCN

Regards,

Read only

0 Likes
1,935

Hi David,

I'm not working on Smartforms , My requirement is to upload file from Presentation server (From Desktop) and count the No.of pages in PDF Document.

With PDF Pages count , I have to calculate some fee.

Thanks

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,935

Hi,

How about using external java command

See http://pdfbox.apache.org/index.html

Found here http://stackoverflow.com/questions/4134949/determine-the-number-of-pages-in-a-pdf-file

PDDocument doc = PDDocument.load(new File("file.pdf"));

int count = doc.getNumberOfPages();

 

Regards .

Read only

0 Likes
1,935

Hi Eitan

Can you please elaborate more , I wants to do it in SAP ABAP Environment.

Thanks

Read only

0 Likes
1,935

Hi,

You have a very exotic task here....

See here the use of java from SAP.

I think that I your case you will need to :

- Load the file (CL_GUI_FRONTEND_SERVICES)

- Save to a folder accessible by SAP .

- Run your external command to measure the FILE.

Regards.

Read only

0 Likes
1,935

Some java code:

import java.io.File;

import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;

public class Main {

    public static void main(String[] args) {

        {

            // For test...

            if (args.length == 0) {

                args = new String[] { "H:/Temp/An Easy Reference for ALV Grid Control.pdf" };

            }

        }

        try {

            final File file = new File(args[0]);

            final PDDocument document = PDDocument.load(file);

            final int numberOfPages = document.getNumberOfPages();

            System.out.println(String.format("%d %s", numberOfPages, file.getName()));

        } catch (final IOException exception) {

            exception.printStackTrace();

        }

    }

}

Seems to be working.....

Regards.