5 Replies Latest reply on Jul 12, 2011 9:34 PM by Max Dunn

    Export PDF throwing error

    xmlapi Level 1

      This works fine in Indesign Desktop but does not work in Indesign server (the code is using c#):

       

      PDFExportPreset highestQualityPrint = a.PDFExportPresets.FindItems("[Highest Quality Print]");

      doc.Export(Format: idExportFormat.idPDFType, To: "C:\test.pdf", ShowingOptions: false, Using: highestQualityPrint, VersionComments: Type.Missing, ForceSave: false);

       

      It's throwing the exception:

      Invalid value for parameter 'Using' of method 'Export'. Expected PDFExportPreset, but received FALSE.
         at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
         at InDesignServer.Document.Export(Object Format, String To, Boolean ShowingOptions, Object Using, Object VersionComments, Boolean ForceSave)

       

       

      Why is this???

        • 1. Re: Export PDF throwing error
          John Hawkinson Level 5

          Perhaps you mean "HIgh Quality Print" instead of "Highest"?

          • 2. Re: Export PDF throwing error
            xmlapi Level 1

            Sorry, that's a typo (it's correct in the actual code). Any idea what's causing this issue?

            • 3. Re: Export PDF throwing error
              xmlapi Level 1

              Okay, I fixed the problem:

               

              Replaced: doc.Export(idExportFormat.idPDFType, "c:\test.pdf", false, smallestFileSize);

              With: NewLateBinding.LateCall(doc, null, "Export", new object[3] { idExportFormat.idPDFType, Utility.PDFFolder + "\\" + filename.Replace(".indd", ".pdf"), smallestFileSize }, null, null, null, true);

               

              It looks like the Indesign Server API "Export" method ONLY accepts 3 parameters: Format, filename, and PDF preset

               

              The API library I have states that the Export method accepts 6 parameters: Format, filename, showingOptions, pdf preset, version comments, force save.

               

              This is strange since the API library was generated using Indesign Server's OWN TLB file. Using stack trace, I found out that no method signature existed for the 6 parameter version.

               

              Using named parameters doesn't work either:

              doc.Export(Format: idExportFormat.idPDFType, To: "c:\test.pdf", false, Using: smallestFileSize);

              • 4. Re: Export PDF throwing error
                Max Dunn Level 1

                Hi xmlapi,

                 

                InDesign can't really use named parameters. Sometimes it looks like it can, but you can't really trust it.

                 

                It looks to me like "smallestFileSize" is the main culprit here. You should probably get a reference to the PDF export preset you want to use and then use that in the export statement (without named parameters). This may confuse C#, since the PDF export preset parameter can accept a string, a PDF export preset object, or an enumeration (i.e., it's a VBScript Variant type). You might be better off sending InDesign server a JavaScript or VBScript using app.doScript.

                 

                Thanks,

                 

                Ole

                • 5. Re: Export PDF throwing error
                  Max Dunn Level 1

                  Funny, I seem to be appearing as Max Dunn (my boss, president of Silicon Publishing). But it doesn't really matter--he'd say the same thing.:-)

                   

                  Thanks,

                   

                  Ole