Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5477 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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

Posted

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?

Posted

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();

Posted

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?

Posted

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

Posted

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...
Posted

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

Posted

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!

This topic is 5477 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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