当前位置: 首页>>代码示例>>C#>>正文


C# PdfCopy.SetMergeFields方法代码示例

本文整理汇总了C#中iTextSharp.text.pdf.PdfCopy.SetMergeFields方法的典型用法代码示例。如果您正苦于以下问题:C# PdfCopy.SetMergeFields方法的具体用法?C# PdfCopy.SetMergeFields怎么用?C# PdfCopy.SetMergeFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.pdf.PdfCopy的用法示例。


在下文中一共展示了PdfCopy.SetMergeFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LargeFilePerformanceTest

        public virtual void LargeFilePerformanceTest() {
            const string target = "PdfCopyTest/";
            const string output = "copyLargeFile.pdf";
            const string cmp = "cmp_copyLargeFile.pdf";
            
            Directory.CreateDirectory(target);

            Stopwatch timer = new Stopwatch();
            timer.Start();

            PdfReader firstSourceReader = new PdfReader(RESOURCES + "frontpage.pdf");
            PdfReader secondSourceReader = new PdfReader(RESOURCES + "large_pdf.pdf");

            Document document = new Document();

            PdfCopy copy = new PdfCopy(document, File.Create(target + output));
            copy.SetMergeFields();

            document.Open();
            copy.AddDocument(firstSourceReader);
            copy.AddDocument(secondSourceReader);

            copy.Close();
            document.Close();

            timer.Stop();
            Console.WriteLine(timer.ElapsedMilliseconds);

            CompareTool cmpTool = new CompareTool();
            String errorMessage = cmpTool.CompareByContent(target + output, RESOURCES + cmp, target, "diff");

            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:35,代码来源:PdfCopyTest.cs

示例2: CopyFields4Test

        public virtual void CopyFields4Test() {
            string target = "PdfCopyTest/";
            Directory.CreateDirectory(target);
            const string outfile = "copyFields4.pdf";
            const string inputFile = "link.pdf";

            Document document = new Document();
            MemoryStream stream = new MemoryStream();
            PdfWriter.GetInstance(document, stream);
            Font font = new Font(BaseFont.CreateFont(RESOURCES + "fonts/georgia.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 9);
            document.Open();
            document.Add(new Phrase("text", font));
            document.Close();

            Document pdfDocument = new Document();
            PdfCopy copier = new PdfCopy(pdfDocument, new FileStream(target + outfile, FileMode.Create));
            copier.SetMergeFields();
            pdfDocument.Open();

            PdfReader reader1 = new PdfReader(RESOURCES + inputFile);
            PdfReader reader2 = new PdfReader(stream.ToArray());

            copier.AddDocument(reader1);
            copier.AddDocument(reader2);
            copier.Close();
            CompareTool cmpTool = new CompareTool();
            string errorMessage = cmpTool.CompareByContent(target + outfile, RESOURCES + "cmp_" + outfile, target, "diff");
            if (errorMessage != null)
                Assert.Fail(errorMessage);
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:30,代码来源:PdfCopyTest.cs

示例3: CopyFields3Test

        public virtual void CopyFields3Test() {
            Document pdfDocument = new Document();
            Directory.CreateDirectory("PdfCopyTest/");
            PdfCopy copier = new PdfCopy(pdfDocument, new FileStream("PdfCopyTest/copyFields3.pdf", FileMode.Create));
            copier.SetMergeFields();
            pdfDocument.Open();

            PdfReader reader = new PdfReader(RESOURCES + "hello2_with_comments.pdf");
            copier.AddDocument(reader);
            copier.Close();
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent("PdfCopyTest/copyFields3.pdf", RESOURCES + "cmp_copyFields3.pdf", "PdfCopyTest/", "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:16,代码来源:PdfCopyTest.cs

示例4: 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);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:26,代码来源:PdfCopyTest.cs

示例5: TestFullCompression2

        public virtual void TestFullCompression2() {
            Directory.CreateDirectory("PdfCopyTest/");
            String outfile = "PdfCopyTest/out-forms.pdf";
            String first = RESOURCES + "subscribe.pdf";
            String second = RESOURCES + "filled_form_1.pdf";
            FileStream out_ = new FileStream(outfile, FileMode.Create);
            PdfReader reader = new PdfReader(first);
            PdfReader reader2 = new PdfReader(second);
            Document pdfDocument = new Document();
            PdfCopy pdfCopy = new PdfCopy(pdfDocument, out_);
            pdfCopy.SetMergeFields();
            pdfCopy.SetFullCompression();
            pdfCopy.CompressionLevel = PdfStream.BEST_COMPRESSION;
            pdfDocument.Open();
            pdfCopy.AddDocument(reader);
            pdfCopy.AddDocument(reader2);
            pdfCopy.Close();
            reader.Close();
            reader2.Close();

            reader = new PdfReader("PdfCopyTest/out-forms.pdf");
            Assert.NotNull(reader.GetPageN(1));
            reader.Close();
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:24,代码来源:PdfCopyTest.cs

示例6: TestNeedAppearancesMixed

        public virtual void TestNeedAppearancesMixed() {
            String f1 = RESOURCES + "appearances1.pdf";
            String f2 = RESOURCES + "appearances2(needAppearancesFalse).pdf";
            String f3 = RESOURCES + "appearances3(needAppearancesFalseWithStreams).pdf";
            String f4 = RESOURCES + "appearances4.pdf";

            Directory.CreateDirectory("PdfCopyTest/");
            FileStream outputPdfStream =
                new FileStream("PdfCopyTest/appearances(mixed).pdf", FileMode.Create);
            Document document = new Document();
            PdfCopy copy = new PdfCopy(document, outputPdfStream);
            copy.SetMergeFields();
            document.Open();
            foreach (String f in new String[] {f1, f2, f3, f4}) {
                PdfReader r = new PdfReader(f);
                copy.AddDocument(r);
            }
            copy.Close();
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent("PdfCopyTest/appearances(mixed).pdf", RESOURCES + "cmp_appearances(mixed).pdf", "PdfCopyTest/", "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:24,代码来源:PdfCopyTest.cs


注:本文中的iTextSharp.text.pdf.PdfCopy.SetMergeFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。