首页 > 代码库 > c#实现pdf另存为功能

c#实现pdf另存为功能

c#实现pdf另存为功能

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/// <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();
}

  转载:http://bbs.it-home.org/forum-net-2.html