本文整理匯總了C#中iTextSharp.text.pdf.PdfCopy.CopyDocumentFields方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfCopy.CopyDocumentFields方法的具體用法?C# PdfCopy.CopyDocumentFields怎麽用?C# PdfCopy.CopyDocumentFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfCopy
的用法示例。
在下文中一共展示了PdfCopy.CopyDocumentFields方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CombineMultiplePDFs
public static void CombineMultiplePDFs(string[] fileNames, string outFile)
{
try
{
iTextSharp.text.Document document = new iTextSharp.text.Document();
PdfCopy writer = new PdfCopy(document, new FileStream(outFile, FileMode.Create));
if (writer == null)
{
return;
}
document.Open();
foreach (string fileName in fileNames)
{
if (System.IO.File.Exists(fileName))
{
PdfReader reader = new PdfReader(fileName);
reader.ConsolidateNamedDestinations();
for (int i = 1; i <= reader.NumberOfPages; i++)
{
PdfImportedPage page = writer.GetImportedPage(reader, i);
writer.AddPage(page);
}
PRAcroForm form = reader.AcroForm;
if (form != null)
{
writer.CopyDocumentFields(reader);
}
reader.Close();
}
}
writer.Close();
document.Close();
}
catch
{
MessageBox.Show("Close the pdf file and try again.");
}
}
示例2: CopyFields1Test
public virtual void CopyFields1Test() {
Document pdfDocument = new Document();
Directory.CreateDirectory("PdfCopyTest/");
PdfCopy copier = new PdfCopy(pdfDocument, new FileStream("PdfCopyTest/copyFields.pdf", FileMode.Create));
copier.SetMergeFields();
pdfDocument.Open();
PdfReader readerMain = new PdfReader(RESOURCES + "fieldsOn3-sPage.pdf");
PdfReader secondSourceReader = new PdfReader(RESOURCES + "fieldsOn2-sPage.pdf");
PdfReader thirdReader = new PdfReader(RESOURCES + "appearances1.pdf");
copier.AddDocument(readerMain);
copier.CopyDocumentFields(secondSourceReader);
copier.AddDocument(thirdReader);
copier.Close();
readerMain.Close();
secondSourceReader.Close();
thirdReader.Close();
CompareTool compareTool = new CompareTool();
String errorMessage = compareTool.CompareByContent("PdfCopyTest/copyFields.pdf", RESOURCES + "cmp_copyFields.pdf", "PdfCopyTest/", "diff");
if (errorMessage != null) {
Assert.Fail(errorMessage);
}
}