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.

Scriptmaster 4.42- Convert Pdf into text

Featured Replies

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

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!

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 )

  • Author

Hi,

It works fin adding both bcprov-jdk15on-152.jar and bcpkix-jdk15on-152.jar

Shall I close the topic ?

Thanks and regards

Olivier

Edited by Olivier Chenot

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.