Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to get PDF properties such as PageCount

Featured Replies

I read that you can use iText in ScriptMaster to manipulate a PDF file. I was wondering if someone can give me a script to find out the pagecount of a PDF file. Like the GetFileSize (filePath) but instead of returning the File Size, returns the Page Count.

I'm not even sure how to import the iText.jar into ScriptMaster. I added it using the Add button on ScriptMaster, but do I need to add it once? Or do I have to also open it in my other solution?

Thanks.

I read that you can use iText in ScriptMaster to manipulate a PDF file. I was wondering if someone can give me a script to find out the pagecount of a PDF file. Like the GetFileSize (filePath) but instead of returning the File Size, returns the Page Count.

I can give an estimate for writing this ScriptMaster module, if you're interested.

I'm not even sure how to import the iText.jar into ScriptMaster. I added it using the Add button on ScriptMaster, but do I need to add it once? Or do I have to also open it in my other solution?

Just adding the jar should suffice, all the jars get loaded at startup of ScriptMaster.fp7

  • Author

I can give an estimate for writing this ScriptMaster module, if you're interested.

Sure, I'm interested.

Just adding the jar should suffice, all the jars get loaded at startup of ScriptMaster.fp7

What if I don't want to use the ScriptMaster.fp7? I loaded some of the modules into my own solution by adding them into my startup script. I guess I would need to add SMLoadJar on my startup if I want to use iText.jar?

Yes you would need to use SMLoadJar to load any additional libraries such as iText.

Here is the iText code for the page count though

PdfReader reader = new PdfReader("some.pdf ");

int n = reader.getNumberOfPages();

  • Author

Yes you would need to use SMLoadJar to load any additional libraries such as iText.

Here is the iText code for the page count though

PdfReader reader = new PdfReader("some.pdf ");

int n = reader.getNumberOfPages();

Thank you so much!

I don't know if I'm doing this right but I cannot Register the Function in the ScriptMaster.

I added and iText.jar in the Jar Libraries then created the script..

PdfReader reader = new PdfReader("some.pdf ");

int n = reader.getNumberOfPages();

And then when I click the Register Function it gave me an error message..

"You cannot register this function, because it will not compile"

What do you think am I mising here?

Probably b/c you're missing an import statement.

There is no class PdfReader in Java runtime, you need explicitly add import statement that import individual classes or packages from third party jars.

Try adding:

import com.lowagie.text.pdf.PdfReader

  • Author

Probably b/c you're missing an import statement.

There is no class PdfReader in Java runtime, you need explicitly add import statement that import individual classes or packages from third party jars.

Try adding:

import com.lowagie.text.pdf.PdfReader

Awesome! Works perfect! :thumbup:

:yourock:

  • 4 weeks later...

For the life of me, I cannot get this to work. I've loaded the iText jar into ScriptMaster, and created a new script.

However, I cannot get this script to recognize that it needs an input variable. So, in FM, it lists as PDF PageCount, and does not expect a parameter.

I'm definitely overlooking something obvious.

SMGrab1.pdf

Grab2.pdf

Perseverance! I fell for the once you've registered it won't reregister until you SMReset or quit FM.

Also, I fed it a FM path, and not an OS path.

I feel so smart!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.