c implements pdf's save as function

  • 2020-06-15 10:09:02
  • OfStack

Today I'm going to share with you an implementation of PDF save as that calls Acrobat SDK.


/// <summary>
        /// PDF Save as an effect 
        /// </summary>
        /// <param name="fileName">PDF The file name </param>
        /// <param name="saveFileName"> Save the result file name </param>
        public static void PDFSaveAs(String fileName, string saveFileName)
        {
            Acrobat.CAcroPDDoc pdfDoc = null;
            pdfDoc = (Acrobat.CAcroPDDoc)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.PDDoc", "");
            if (!pdfDoc.Open(fileName)) { string.Format(" The source file {0} Does not exist! ", fileName); }
            Object jsObj = pdfDoc.GetJSObject();
            Type T = jsObj.GetType();

            object[] saveAsParam = { saveFileName, "com.adobe.acrobat.tiff" }; //com.adobe.acrobat.tiff  said TIFF file 
            T.InvokeMember(
                "saveAs",
                BindingFlags.InvokeMethod |
                BindingFlags.Public |
                BindingFlags.Instance,
                null, jsObj, saveAsParam);
            pdfDoc.Close();
        }


Related articles: