public virtual void CopyFieldsTest07() { String srcFilename = sourceFolder + "datasheet.pdf"; String destFilename = destinationFolder + "copyFields07.pdf"; PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename)); PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); // copying the same page from reopened document twice for (int i = 0; i < 2; ++i) { PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFilename)); srcDoc.CopyPagesTo(1, 1, destDoc, pdfPageFormCopier); srcDoc.Close(); } destDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destFilename, sourceFolder + "cmp_copyFields07.pdf" , destinationFolder, "diff_")); }
public virtual void LargeFileTest() { String srcFilename1 = sourceFolder + "frontpage.pdf"; String srcFilename2 = sourceFolder + "largeFile.pdf"; String filename = destinationFolder + "copyLargeFile.pdf"; PdfDocument doc1 = new PdfDocument(new PdfReader(srcFilename1)); PdfDocument doc2 = new PdfDocument(new PdfReader(srcFilename2)); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(filename)); pdfDoc.InitializeOutlines(); PdfPageFormCopier formCopier = new PdfPageFormCopier(); doc1.CopyPagesTo(1, doc1.GetNumberOfPages(), pdfDoc, formCopier); doc2.CopyPagesTo(1, 10, pdfDoc, formCopier); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(filename, sourceFolder + "cmp_copyLargeFile.pdf" , destinationFolder, "diff_")); }
public virtual void CopyFieldsTest09() { String srcFilename = sourceFolder + "datasheet.pdf"; String destFilename = destinationFolder + "copyFields09.pdf"; PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename, new WriterProperties().UseSmartMode())); // copying the same page from the same document twice PdfPageFormCopier copier = new PdfPageFormCopier(); for (int i = 0; i < 3; ++i) { PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFilename)); srcDoc.CopyPagesTo(1, 1, destDoc, copier); destDoc.FlushCopiedObjects(srcDoc); srcDoc.Close(); } destDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destFilename, sourceFolder + "cmp_copyFields09.pdf" , destinationFolder, "diff_")); }
public virtual void CopyFieldsTest13() { String srcFilename = sourceFolder + "copyFields13.pdf"; String destFilename = destinationFolder + "copyFields13.pdf"; PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFilename)); PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename)); PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); for (int i = 0; i < 1; ++i) { srcDoc.CopyPagesTo(1, 1, destDoc, pdfPageFormCopier); } PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(destDoc, false); acroForm.GetField("text").SetValue("Text!"); destDoc.Close(); srcDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destFilename, sourceFolder + "cmp_copyFields13.pdf" , destinationFolder, "diff_")); }
public virtual void LargeFilePerformanceTest() { String srcFilename1 = sourceFolder + "frontpage.pdf"; String srcFilename2 = sourceFolder + "largeFile.pdf"; String filename = destinationFolder + "copyLargeFile.pdf"; long timeStart = System.DateTime.Now.Ticks; PdfDocument doc1 = new PdfDocument(new PdfReader(srcFilename1)); PdfDocument doc2 = new PdfDocument(new PdfReader(srcFilename2)); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(filename)); pdfDoc.InitializeOutlines(); PdfPageFormCopier formCopier = new PdfPageFormCopier(); doc1.CopyPagesTo(1, doc1.GetNumberOfPages(), pdfDoc, formCopier); doc2.CopyPagesTo(1, doc2.GetNumberOfPages(), pdfDoc, formCopier); pdfDoc.Close(); System.Console.Out.WriteLine(((System.DateTime.Now.Ticks - timeStart) / 1000 / 1000)); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(filename, sourceFolder + "cmp_copyLargeFile.pdf" , destinationFolder, "diff_")); }
public virtual void CopyFieldsTest08() { String srcFilename1 = sourceFolder + "appearances1.pdf"; String srcFilename2 = sourceFolder + "fieldsOn2-sPage.pdf"; String srcFilename3 = sourceFolder + "fieldsOn3-sPage.pdf"; String filename = destinationFolder + "copyFields08.pdf"; PdfDocument doc1 = new PdfDocument(new PdfReader(srcFilename1)); PdfDocument doc2 = new PdfDocument(new PdfReader(srcFilename2)); PdfDocument doc3 = new PdfDocument(new PdfReader(srcFilename3)); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(filename)); pdfDoc.InitializeOutlines(); PdfPageFormCopier formCopier = new PdfPageFormCopier(); doc3.CopyPagesTo(1, doc3.GetNumberOfPages(), pdfDoc, formCopier); doc2.CopyPagesTo(1, doc2.GetNumberOfPages(), pdfDoc, formCopier); doc1.CopyPagesTo(1, doc1.GetNumberOfPages(), pdfDoc, formCopier); pdfDoc.Close(); // comparing with cmp_copyFields01.pdf on purpose: result should be the same as in the first test NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(filename, sourceFolder + "cmp_copyFields01.pdf" , destinationFolder, "diff_")); }
public virtual void CopyAndEditRadioButtons() { //TODO: update after DEVSIX-2354 String srcFileName = sourceFolder + "/checkPdfFormCopy_Source.pdf"; String destFilename = destinationFolder + "copyAndEditRadioButtons.pdf"; String cmpFileName = sourceFolder + "/cmp_copyAndEditRadioButtons.pdf"; PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFileName)); PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename)); PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); for (int i = 0; i < 4; i++) { srcDoc.CopyPagesTo(1, 1, destDoc, pdfPageFormCopier); } PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(destDoc, false); acroForm.GetField("Group.4").SetValue("Choice_3!<>3.3.3"); destDoc.Close(); srcDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destFilename, cmpFileName, destinationFolder , "diff_")); }
public virtual void CopyMultipleSubfieldsSmartModeTest01() { String srcFilename = sourceFolder + "copyMultipleSubfieldsSmartModeTest01.pdf"; String destFilename = destinationFolder + "copyMultipleSubfieldsSmartModeTest01.pdf"; PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFilename)); PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename).SetSmartMode(true)); PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); // copying the same page from the same document twice for (int i = 0; i < 4; ++i) { srcDoc.CopyPagesTo(1, 1, destDoc, pdfPageFormCopier); } PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(destDoc, false); acroForm.GetField("text_1").SetValue("Text 1!"); acroForm.GetField("text_2").SetValue("Text 2!"); acroForm.GetField("text.3").SetValue("Text 3!"); acroForm.GetField("text.4").SetValue("Text 4!"); destDoc.Close(); srcDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsSmartModeTest01.pdf" , destinationFolder, "diff_")); }