我可以做我想要的,即打开2个PDF,将第一个合并到第二个,然后保存。
AcroAVDoc avFrom = new AcroAVDocClass();
AcroAVDoc avTo = new AcroAVDocClass();
AcroPDDoc pdFrom;
AcroPDDoc pdTo;
if (avFrom.Open (fileinfo.FullName, ""))
{
pdFrom = (AcroPDDoc)avFrom.GetPDDoc();
if (avTo.Open(combinedFullPath, ""))
{
pdTo = (AcroPDDoc)avTo.GetPDDoc();
pdTo.InsertPages(pdTo.GetNumPages() - 1, pdFrom, 0, pdFrom.GetNumPages(), 0);
pdTo.Save(1, combinedFullPath);
Adobe.CloseAllDocs();
}
else
{
Debug.Write("Failed to open combined pdf to merge with: " + CaseNo);
}
}
问题是,当我循环数千次时,Adobe窗口会打开并减慢所有内容。
有谁知道如何将所有这些保留在代码中?
答案 0 :(得分:1)
AcroPDDoc pdFrom = new AcroPDDoc();
AcroPDDoc pdTo = new AcroPDDoc();
if (pdFrom.Open (fileinfo.FullName))
{
if (pdTo.Open(combinedFullPath))
{
pdTo.InsertPages(pdTo.GetNumPages() - 1, pdFrom, 0, pdFrom.GetNumPages(), 0);
pdTo.Save(1, combinedFullPath);
pdFrom.Close();
pdTo.Close();
}
else
{
pdFrom.Close();
Debug.Write("Failed to open combined pdf to merge with: " + CaseNo);
}
}
}