Jump to content

Scriptmaster 4.42- Convert Pdf into text


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

Recommended Posts

Hi everybody

I have an error using scriptmaster 4.42 release when I try to convert a pdf file into text. I have no problem with 4.201 release.

The function reurns ERROR and SMLastError is set as "java.lang.NoClassDefFoundError: org/bouncycastle/cms/Recipient"

My function is defined as

"import java.io.IOException" & ¶ &
"import com.itextpdf.text.pdf.PdfReader" & ¶ &
"import com.itextpdf.text.pdf.parser.PdfTextExtractor" & ¶ &
¶ &
"if( fm_filePath == null ){ throw new Exception(\"File path required !\")}" & ¶ &
"if (new File( fm_filePath ).exists()){" & ¶ &
"  try{" & ¶ &
"    reader = new PdfReader(fm_filePath)" & ¶ &
"    sb = new StringBuffer()" & ¶ &
"    for (int i = 1; i <= reader.numberOfPages; i++) {" & ¶ &
"      sb.append(PdfTextExtractor.getTextFromPage(reader, i))" & ¶ &
"    }" & ¶ &
"    return sb " & ¶ &
"  } catch (IOException e) {" & ¶ &
"    e.printStackTrace()" & ¶ &
"    return \"IO ERROR.\"" & ¶ &
"  } catch (Exception e) {" & ¶ &
"    e.printStackTrace()" & ¶ &
"    return \"ERROR.\"" & ¶ &
"  }" & ¶ &
"}"

Starting from SMLastError I added bouncycastle jar in my filemaker solution. No change, so I tried to add as well such as import steps :

"import java.io.*" & ¶ &
"import java.util.*" & ¶ &
"import java.security.*" & ¶ &

"import org.bouncycastle.jce.provider.BouncyCastleProvider" & ¶ &

I found these steps on other forums, but without any documentation, it looks like fishing...

One thing changes : when I use "import org.bouncycastle.jce.provider.BouncyCastleProvider" SMLastError becomes

java.lang.NoClassDefFoundError: org/bouncycastle/cms/RecipientId

instead of

java.lang.NoClassDefFoundError: org/bouncycastle/cms/Recipient

Thanks in advance

Olivier

Link to comment
Share on other sites

Olivier, this is showing up in ScriptMaster 4.42 because we updated to a newer version of Groovy in newer versions. If you include both the provider jar and the CMS jar (bcprov-jdk15on-152.jar and bcpkix-jdk15on-152.jar), which you can download from https://www.bouncycastle.org/latest_releases.html , this should work correctly. Let me know if you have any trouble!

Link to comment
Share on other sites

You don't need to alter the code to explicitly call the bouncy castle jars, it is just that PdfReader uses them to check for user passwords and a couple do father things so they have a dependancy on them being loaded.

As Evan says, previously the build of ScriptMaster included a version of Groovy that already had them in the JVM

be more groovy...  for ( i in 1..reader.numberOfPages )

Link to comment
Share on other sites

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