例子,c#实现PDF另存为,调用Acrobat SDK的javascript实现。
代码:
/// <summary>
/// PDF另存为效果
/// </summary>
/// <param name="fileName">PDF文件名</param>
/// <param name="saveFileName">另存结果文件名</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("源文件{0}不存在!", fileName); }
Object jsObj = pdfDoc.GetJSObject();
Type T = jsObj.GetType();
object[] saveAsParam = { saveFileName, "com.adobe.acrobat.tiff" }; //com.adobe.acrobat.tiff 表示TIFF文件
T.InvokeMember(
"saveAs",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Instance,
null, jsObj, saveAsParam);
pdfDoc.Close();
}