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

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

Recommended Posts

Posted

Between the various tools how would I get the page count of a PDF

iText & ScriptMaster

SuperContainer Plugin

Scribe

Posted

Thanks john renfrew




RegisterGroovy( "PDFpage( filePathName ; masterPass )" ; "import com.itextpdf.text.pdf.PdfReader¶

if (masterPass == null) {¶

OWNER = null¶

} else {¶

OWNER = masterPass.getBytes()¶

} //end if¶

try {¶

reader = new PdfReader(filePathName, OWNER)¶

} catch (Exception e) {¶

if (e.toString().contains('BadPassword')) {¶

  return 'PASSWORD ERROR'¶

} else {¶

  return 'ERROR'¶

}//end if¶

return reader.getNumberOfPages()" )

  • 5 months later...
  • Newbies
Posted

I loaded the iText jar, registered the function, but in text viewer, I'm getting this string:

com.itextpdf.text.pdf.PdfReader@17361e2

What am I doing wrong?

Thanks!

Posted

Nothing

There is a TINY mistake

Last three lines should be


}//end if

}//end try

return reader.getNumberOfPages()

without the missing closing } you are just returning the fact that there is a reader object created as the getPages needs to be outside the try

This topic is 4566 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.