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


C# CompareTool.CompareByContent方法代码示例

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


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

示例1: Rowspan_Test

        public virtual void Rowspan_Test() {
            String file = "rowspantest.pdf";

            string fileE = CMP_FOLDER + file;
            Console.Write(File.Exists(fileE));
            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(OUTPUT_FOLDER + file, FileMode.Create));
            document.Open();
            PdfContentByte contentByte = writer.DirectContent;

            Rectangle rect = document.PageSize;

            PdfPTable table = new PdfPTable(4);

            table.TotalWidth = rect.Right - rect.Left + 1;
            table.LockedWidth = true;

            float[] widths = new float[] {
                0.1f, 0.54f, 0.12f, 0.25f
            };

            table.SetWidths(widths);

            PdfPCell cell_1_1 = new PdfPCell(new Phrase("1-1"));
            cell_1_1.Colspan = 4;
            table.AddCell(cell_1_1);

            PdfPCell cell_2_1 = new PdfPCell(new Phrase("2-1"));
            cell_2_1.Rowspan = 2;
            table.AddCell(cell_2_1);

            PdfPCell cell_2_2 = new PdfPCell(new Phrase("2-2"));
            cell_2_2.Colspan = 2;
            table.AddCell(cell_2_2);

            PdfPCell cell_2_4 = new PdfPCell(new Phrase("2-4"));
            cell_2_4.Rowspan = 3;
            table.AddCell(cell_2_4);

            PdfPCell cell_3_2 = new PdfPCell(new Phrase("3-2"));
            table.AddCell(cell_3_2);

            PdfPCell cell_3_3 = new PdfPCell(new Phrase("3-3"));
            table.AddCell(cell_3_3);

            PdfPCell cell_4_1 = new PdfPCell(new Phrase("4-1"));
            cell_4_1.Colspan = 3;
            table.AddCell(cell_4_1);

            table.WriteSelectedRows(0, -1, rect.Left, rect.Top, contentByte);

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool(OUTPUT_FOLDER + file, CMP_FOLDER + file);
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:60,代码来源:RowspanTest.cs

示例2: Test

        public void Test() {
            String file = "tagged_pdf_end_page.pdf";

            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(OUTPUT_FOLDER + file, FileMode.Create));
            writer.PdfVersion = PdfWriter.VERSION_1_7;
            writer.SetTagged();
            writer.CreateXmpMetadata();
            document.SetMargins(10, 10, 60, 10);

            PdfPTable headerTable = new PdfPTable(1);

            PdfPageHeader header = new CustomPdfPageHeader(writer, 10, headerTable);

            writer.PageEvent = header;

            document.Open();

            PdfPTable table = CreateContent();
            document.Add(table);

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool().SetFloatRelativeError(1e-4f);
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, TEST_RESOURCES_PATH + file,
                OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:31,代码来源:TaggedPdfOnEndPageTest.cs

示例3: TextLeadingTest

        public void TextLeadingTest() {
            String file = "phrases.pdf";

            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, File.Create(OUTPUT_FOLDER + file));
            document.Open();

            Phrase p1 = new Phrase("first, leading of 150");
            p1.Leading = 150;
            document.Add(p1);
            document.Add(Chunk.NEWLINE);

            Phrase p2 = new Phrase("second, leading of 500");
            p2.Leading = 500;
            document.Add(p2);
            document.Add(Chunk.NEWLINE);

            Phrase p3 = new Phrase();
            p3.Add(new Chunk("third, leading of 20"));
            p3.Leading = 20;
            document.Add(p3);

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, TEST_RESOURCES_PATH + file, OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:31,代码来源:DocumentLayoutTest.cs

示例4: Test

        public void Test() {
            String file = "tagged_pdf_page_events.pdf";

            Document document = new Document();

            PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(OUTPUT_FOLDER + file, FileMode.Create));

            pdfWriter.SetTagged();
            pdfWriter.PageEvent = new TaggedPdfPageEventsTest();

            document.Open();

            document.Add(new Paragraph("Hello"));
            document.NewPage();
            document.Add(new Paragraph("World"));

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, TEST_RESOURCES_PATH + file,
                OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:26,代码来源:TaggedPdfPageEventsTest.cs

示例5: PageEventTest01

        public void PageEventTest01() {
            String fileName = "pageEventTest01.pdf";

            MemoryStream baos = new MemoryStream();
            Document doc = new Document(PageSize.LETTER, 144, 144, 144, 144);
            PdfWriter writer = PdfWriter.GetInstance(doc, baos);
            writer.PageEvent = new MyEventHandler();

            writer.SetTagged();
            doc.Open();

            Chunk c = new Chunk("This is page 1");
            doc.Add(c);

            doc.Close();

            File.WriteAllBytes(OUTPUT_FOLDER + fileName, baos.ToArray());
            baos.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + fileName, TEST_RESOURCES_PATH + fileName, OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:26,代码来源:PageEventTest.cs

示例6: TextWithSymbolEncoding

        public virtual void TextWithSymbolEncoding() {
            BaseFont f = BaseFont.CreateFont(BaseFont.SYMBOL, BaseFont.SYMBOL, false);
            FileStream fs = new FileStream("fonts/SymbolFontTest/textWithSymbolEncoding.pdf", FileMode.Create);
            Document doc = new Document();
            PdfWriter writer = PdfWriter.GetInstance(doc, fs);
            Paragraph p;
            writer.CompressionLevel = 0;
            doc.Open();

            String origText = "ΑΒΓΗ€\u2022\u2663\u22c5";
            p = new Paragraph(new Chunk(origText, new Font(f, 16)));
            doc.Add(p);
            doc.Close();

            PdfReader reader = new PdfReader("fonts/SymbolFontTest/textWithSymbolEncoding.pdf");
            String text = PdfTextExtractor.GetTextFromPage(reader, 1, new SimpleTextExtractionStrategy());
            reader.Close();
            Assert.AreEqual(origText, text);

            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent("fonts/SymbolFontTest/textWithSymbolEncoding.pdf", TEST_RESOURCES_PATH + "cmp_textWithSymbolEncoding.pdf", "fonts/SymbolFontTest/", "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:25,代码来源:SymbolTest.cs

示例7: VerticalPositionTest0

        public void VerticalPositionTest0() {
            String file = "vertical_position.pdf";

            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, File.Create(OUTPUT_FOLDER + file));
            document.Open();

            writer.PageEvent = new CustomPageEvent();

            PdfPTable table = new PdfPTable(2);
            for (int i = 0; i < 100; i++) {
                table.AddCell("Hello " + i);
                table.AddCell("World " + i);
            }

            document.Add(table);

            document.NewPage();

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 1000; i++) {
                sb.Append("some more text ");
            }
            document.Add(new Paragraph(sb.ToString()));

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, TEST_RESOURCES_PATH + file,
                OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:35,代码来源:VerticalPositionTest.cs

示例8: CompareDocuments

 private void CompareDocuments(String @out, String cmp, bool visuallyOnly) {
     CompareTool compareTool = new CompareTool();
     String errorMessage;
     if (visuallyOnly) {
         errorMessage = compareTool.Compare(outFolder + @out, cmpFolder + cmp, outFolder, "diff");
     } else {
         errorMessage = compareTool.CompareByContent(outFolder + @out, cmpFolder + cmp, outFolder, "diff");
     }
     if (errorMessage != null)
         Assert.Fail(errorMessage);
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:11,代码来源:NestedTablesTest.cs

示例9: Test2

        public void Test2() {
            CompareTool compareTool = new CompareTool();
            compareTool.SetCompareByContentErrorsLimit(10);
            compareTool.SetGenerateCompareByContentXmlReport(true);

            String outPdf = TEST_RESOURCES_PATH + "tagged_pdf.pdf";
            String cmpPdf = TEST_RESOURCES_PATH + "cmp_tagged_pdf.pdf";
            String result = compareTool.CompareByContent(outPdf, cmpPdf, OUT_FOLDER, "difference");

            Assert.NotNull(result);
            Console.WriteLine(result);
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:12,代码来源:CompareToolTest.cs

示例10: CompareToolErrorReportTest02

 public void CompareToolErrorReportTest02() {
     CompareTool compareTool = new CompareTool();
     compareTool.SetCompareByContentErrorsLimit(10);
     compareTool.SetGenerateCompareByContentXmlReport(true);
     compareTool.SetXmlReportName("report02");
     String outPdf = TEST_RESOURCES_PATH + "tagged_pdf.pdf";
     String cmpPdf = TEST_RESOURCES_PATH + "cmp_tagged_pdf.pdf";
     String result = compareTool.CompareByContent(outPdf, cmpPdf, OUT_FOLDER, "difference");
     Assert.NotNull("CompareTool must return differences found between the files",result);
     Assert.IsTrue(CompareXmls(TEST_RESOURCES_PATH + "cmp_report02.xml", OUT_FOLDER + "report02.xml"), "CompareTool report differs from the reference one");
     Console.WriteLine(result);
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:12,代码来源:CompareToolTest.cs

示例11: ComparePdf

 protected override void ComparePdf(String outPdf, String cmpPdf) {
     if (!DetectCrashesAndHangUpsOnly()) {
         CompareTool compareTool = new CompareTool(outPdf, cmpPdf);
         String errorMessage = null;
         if (CompareByContent())
             errorMessage = compareTool.CompareByContent(outPath, differenceImagePrefix);
         else
             errorMessage = compareTool.Compare(outPath, differenceImagePrefix);
         if (errorMessage != null) {
             Assert.Fail(errorMessage);
         }
     }
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:13,代码来源:SampleTest.cs

示例12: VisibleTopChoiceHelper

        private void VisibleTopChoiceHelper(int topVisible, int expected, String file) {
            Document document = new Document();
            FileStream fos = new FileStream(OUTPUT_FOLDER + file, FileMode.Create);
            PdfWriter writer = PdfWriter.GetInstance(document, fos);
            document.Open();

            TextField textField = new TextField(writer, new Rectangle(380, 560, 500, 610), "testListBox");

            textField.Visibility = BaseField.VISIBLE;
            textField.Rotation = 0;

            textField.FontSize = 14f;
            textField.TextColor = BaseColor.MAGENTA;

            textField.BorderColor = BaseColor.BLACK;
            textField.BorderStyle = PdfBorderDictionary.STYLE_SOLID;

            textField.Font = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED);
            textField.BorderWidth = BaseField.BORDER_WIDTH_THIN;

            writer.RunDirection = PdfWriter.RUN_DIRECTION_LTR;

            textField.Choices = new String[] {"one", "two", "three"};
            textField.ChoiceExports = new String[] {"1", "2", "3"};

            //choose the second item
            textField.ChoiceSelection = 1;
            //set the first item as the visible one
            textField.VisibleTopChoice = topVisible;

            Assert.AreEqual(expected, textField.VisibleTopChoice);

            PdfFormField field = textField.GetListField();

            writer.AddAnnotation(field);

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, CMP_FOLDER + file, OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:45,代码来源:TextFieldTest.cs

示例13: AddNavigationTest

 public void AddNavigationTest()  {
     String src = srcFolder + "primes.pdf";
     String dest = outFolder + "primes_links.pdf";
     PdfReader reader = new PdfReader(src);
     PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create));
     PdfDestination d = new PdfDestination(PdfDestination.FIT);
     Rectangle rect = new Rectangle(0, 806, 595, 842);
     PdfAnnotation a10 = PdfAnnotation.CreateLink(stamper.Writer, rect, PdfAnnotation.HIGHLIGHT_INVERT, 2, d);
     stamper.AddAnnotation(a10, 1);
     PdfAnnotation a1 = PdfAnnotation.CreateLink(stamper.Writer, rect, PdfAnnotation.HIGHLIGHT_PUSH, 1, d);
     stamper.AddAnnotation(a1, 2);
     stamper.Close();
     CompareTool compareTool = new CompareTool();
     String errorMessage = compareTool.CompareByContent(dest, srcFolder + "cmp_primes_links.pdf", outFolder, "diff_");
     if (errorMessage != null) {
         Assert.Fail(errorMessage);
     }
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:18,代码来源:NamedDestinationsTest.cs

示例14: ImageTaggingExpansionTest

        public void ImageTaggingExpansionTest() {
            String filename = "TextExpansionTest.pdf";
            Document doc = new Document(PageSize.LETTER, 72, 72, 72, 72);
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(DEST_FOLDER + filename, FileMode.Create));
            writer.SetTagged();
            doc.Open();

            Chunk c1 = new Chunk("ABC");
            c1.SetTextExpansion("the alphabet");
            Paragraph p1 = new Paragraph();
            p1.Add(c1);
            doc.Add(p1);

            PdfTemplate t = writer.DirectContent.CreateTemplate(6, 6);
            t.SetLineWidth(1f);
            t.Circle(3f, 3f, 1.5f);
            t.SetGrayFill(0);
            t.FillStroke();
            Image i = Image.GetInstance(t);
            Chunk c2 = new Chunk(i, 100, -100);
            doc.Add(c2);

            Chunk c3 = new Chunk("foobar");
            c3.SetTextExpansion("bar bar bar");
            Paragraph p3 = new Paragraph();
            p3.Add(c3);
            doc.Add(p3);

            doc.Close();


            CompareTool compareTool = new CompareTool();
            String error = compareTool.CompareByContent(DEST_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DEST_FOLDER, "diff_");
            if (error != null) {
                Assert.Fail(error);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:37,代码来源:TextExpansionTest.cs

示例15: 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


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