Jump to content

Get PDF Page Count?


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

Recommended Posts

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

Link to comment
Share on other sites

  • 5 months later...
  • Newbies

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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