6 Replies Latest reply on Oct 1, 2012 12:59 PM by MarkB

    Scriptmaster RegisterGroovy Error

    MarkB

      Hey all,

       

      We recently did a full upgrade of our office from FMP11 to FMP12, and we are noticing little quirks. The major one that we are experiencing has to do with 360 Works Scriptmaster. We have a custom function that is run on entering a layout that registered a function called "CatPDF" which when run would take one pdf and place it at the tail end of the target pdf. While in FMP11 the script worked fine and the function was registered with the RegisterGroovy function, however we are finding out that in FMP12, the function doesn't get registered. When checking in the debugger with a data viewer on, I can see that the RegisterGroovy function returns an error. Tried recreating the custom function to no avail. Below is a screenshot of the function. I would be grateful for any help in this:

       

      CatPDF code.jpg

       

      That is from the custom function we call "sm.register.catpdf". When we call it in a script we call it to a variable like so:

       

      Set Variable [$$registerCatPDF; Value:sm.register.catpdf]

       

      The above returns an error in FMP12, when it worked like a charm in FMP11. Any ideas?

        • 1. Re: Scriptmaster RegisterGroovy Error
          jbarnum

          What is the error? Call SMLastError to get the error message.

          • 2. Re: Scriptmaster RegisterGroovy Error
            MarkB

            I have included the error message in the image below. Again, this code was working fine in FMP11 and we haven't changed anything through the conversion.

             

            CatPDF Error.jpg

            • 3. Re: Scriptmaster RegisterGroovy Error
              jbarnum

              See what happens if you remove the word 'try' (keep the curly bracket after it). If this doesn't solve the problem, then please post the text of the ScriptMaster function (as opposed to a screenshot) so I can try compiling it here.

              • 4. Re: Scriptmaster RegisterGroovy Error
                MarkB

                Unfortunately didn't solve the problem, it resulted in this error:

                 

                CatPDF Error 2.jpg

                 

                Here is the text of the original code (that was working in FMP11). It uses the iText jar file:

                 

                RegisterGroovy( "catpdf( files; output )"; "¶

                import java.io.FileOutputStream;¶

                import java.util.ArrayList;¶

                import java.util.List;¶

                import com.lowagie.text.Document;¶

                import com.lowagie.text.pdf.PdfReader;¶

                import com.lowagie.text.pdf.PdfCopy;¶

                import com.lowagie.text.pdf.PdfImportedPage;¶

                try {¶

                  String[] inFiles = files.split(\"\n\");¶

                  int f = 0;¶

                  int pageOffset = 0;¶

                  String outFile = output;¶

                  Document document = null;¶

                  PdfCopy  writer = null;¶

                  while (f < inFiles.length) {¶

                    // Create a reader for the next document¶

                    PdfReader reader = new PdfReader(inFiles[f]);¶

                    reader.consolidateNamedDestinations();¶

                    // Retrieve the total number of pages¶

                    int n = reader.getNumberOfPages();¶

                    pageOffset += n;¶

                    // Create the master document¶

                    if (f == 0) {¶

                      // step 1: Create the document-object¶

                      document = new Document(reader.getPageSizeWithRotation(1));¶

                      // step 2: Create the writer that listens to the document¶

                      writer = new PdfCopy(document, new FileOutputStream(outFile));¶

                      // step 3: Open the document¶

                      document.open();¶

                    }¶

                    // step 4: Add content¶

                    PdfImportedPage page;¶

                    for (int i = 0; i < n; ) {¶

                      ++i;¶

                      page = writer.getImportedPage(reader, i);¶

                      writer.addPage(page);¶

                    }¶

                    f++;¶

                  }¶

                  document.close();¶

                  return outFile;¶

                }" )

                • 5. Re: Scriptmaster RegisterGroovy Error
                  jbarnum

                  Try this. I didn't actually get it to compile because I don't have the iText jars handy right now, but it didn't give me any syntax errors:

                   

                  RegisterGroovy( "catpdf( files; output )"; "¶

                  import java.io.FileOutputStream;¶

                  import java.util.ArrayList;¶

                  import java.util.List;¶

                  import com.lowagie.text.Document;¶

                  import com.lowagie.text.pdf.PdfReader;¶

                  import com.lowagie.text.pdf.PdfCopy;¶

                  import com.lowagie.text.pdf.PdfImportedPage;¶

                            String[] inFiles = files.split(\"\n\");¶

                            int f = 0;¶

                            int pageOffset = 0;¶

                            String outFile = output;¶

                            Document document = null;¶

                            PdfCopy          writer = null;¶

                            while (f < inFiles.length) {¶

                                                // Create a reader for the next document¶

                                                PdfReader reader = new PdfReader(inFiles[f]);¶

                                                reader.consolidateNamedDestinations();¶

                                                // Retrieve the total number of pages¶

                                                int n = reader.getNumberOfPages();¶

                                                pageOffset += n;¶

                                                // Create the master document¶

                                                if (f == 0) {¶

                                                                    // step 1: Create the document-object¶

                                                                    document = new Document(reader.getPageSizeWithRotation(1));¶

                                                                    // step 2: Create the writer that listens to the document¶

                                                                    writer = new PdfCopy(document, new FileOutputStream(outFile));¶

                                                                    // step 3: Open the document¶

                                                                    document.open();¶

                                                }¶

                                                // step 4: Add content¶

                                                PdfImportedPage page;¶

                                                for (int i = 0; i < n; ) {¶

                                                                    ++i;¶

                                                                    page = writer.getImportedPage(reader, i);¶

                                                                    writer.addPage(page);¶

                                                }¶

                                                f++;¶

                            }¶

                            document.close();¶

                            return outFile;¶" )

                  • 6. Re: Scriptmaster RegisterGroovy Error
                    MarkB

                    Worked like a charm! Thank you very much for all of your help!