September 30, 20169 yr Newbies 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.Jar, Itext7-Io-7.0.0.Jar, Itext7-Kernel-7.0.0.Jar, Itext7-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
September 30, 20169 yr It looks like there should be an Itext-Layout-7.0.0.jar file that you can import those needed classes from.
September 30, 20169 yr 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
October 2, 20169 yr Author Newbies 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.
Create an account or sign in to comment