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

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

Recommended Posts

  • Newbies
Posted

Hi, I am very new to using ScriptMaster and have run into some problems when trying to run a few test lines of java. I am trying to create a module that will modify AcroFields on a PDF document, and am therefore going to be using the iText library. I have added this in the Jar Libraries section. Here is the script I am trying to run:

 

import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.forms.PdfAcroForm;

//Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfReader("C:/Users/Andy/Desktop/VA_Form.pdf"), new PdfWriter("C:/Users/Andy/Desktop/New_VA_Form.pdf"));
PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);

and I am getting this error when attempting to run the script:

java.lang.NoClassDefFoundError: com/itextpdf/layout/element/BlockElement

Parameters:
{data="my custom data"}

---Script---
Script:
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.forms.PdfAcroForm;

//Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfReader("C:/Users/Andy/Desktop/VA_Form.pdf"), new PdfWriter("C:/Users/Andy/Desktop/New_VA_Form.pdf"));
PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);
return "true!";

I am not sure how the classpath works in ScriptMaster, but assumed it was to do with this? I have four additional libraries (Itext7-Forms-7.0.0.JarItext7-Io-7.0.0.Jar, Itext7-Kernel-7.0.0.JarItext7-Pdfa-7.0.0.Jar).

Any help is much appreciated, I am really stuck and can't seem to find any help in previous posts.

Thanks

Posted

They have significantly changed the internal dependencies for version 7 

I think this needs 

import com.itextpdf.layout.element.BlockElement too

if you read their API docs you will find the dependencies. I am just getting my head round modifying all my 5.+ code for the v 7 libraries - and waiting for 306works to update the plunging as this only work on a PC due to the Java 6 dependancy on Mac

  • Newbies
Posted

Thank you both for your help with this - it looks like that will solve the problem that I was running into. And John - I had missed the dependencies when I was reading through the APIs i'm sure that will be helpful too; appreciate your advice.

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