• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CompareTool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


示例3: TestFlattening

        public virtual void TestFlattening()
        {
            const string INPUT_FOLDER = RESOURCES_FOLDER + "input/";
            const string CMP_FOLDER = RESOURCES_FOLDER + "cmp/";
            if (File.Exists(INPUT_FOLDER))
                Assert.Fail("Input folder can't be found (" + INPUT_FOLDER + ")");

            Directory.CreateDirectory(OUTPUT_FOLDER);

            String[] files = Directory.GetFiles(INPUT_FOLDER, "*.pdf");

            foreach (String file in files)
            {
                // flatten fields
                PdfReader reader = new PdfReader(file);
                PdfStamper stamper = new PdfStamper(reader, new FileStream(OUTPUT_FOLDER + Path.GetFileName(file), FileMode.Create));
                stamper.FormFlattening = true;
                stamper.Close();

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


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


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


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


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


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

        public void SetPageContentTest02()  {
            String outPdf = DestFolder + "out2.pdf";
            PdfReader reader = new PdfReader(TestResourceUtils.GetResourceAsStream(TestResourcesPath, "in.pdf"));
            PdfStamper stamper = new PdfStamper(reader, new FileStream(outPdf, FileMode.Create));
            int total = reader.NumberOfPages + 1;
            for (int i = 1; i < total; i++) {
                byte[] bb = reader.GetPageContent(i);
                reader.SetPageContent(i, bb);
            }
            reader.RemoveUnusedObjects();
            stamper.Close();

            String s = new CompareTool().CompareByContent(outPdf, TestResourceUtils.GetResourceAsTempFile(TestResourcesPath, "cmp_out2.pdf"), DestFolder, "diff_");
            Assert.Null(s);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:15,代码来源:PdfStamperTest.cs


示例16: WaitingImageTest

        public void WaitingImageTest() {
            String file = "waitingImage.pdf";

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

            String longTextString = "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas" +
                                    "asdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddasasdsaddsdadasddas";
            String extraLongTextString = longTextString + longTextString;
            document.Add(new Paragraph(extraLongTextString));
            String imageFile = "Desert.jpg";
            document.Add(Image.GetInstance(TEST_RESOURCES_PATH + imageFile));

            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,代码行数:28,代码来源:DocumentLayoutTest.cs


示例17: DeviceNSpotBasedGradient

        public virtual void DeviceNSpotBasedGradient() {
            // step 1
            Document document = new Document(PageSize.A3);
            // step 2
            String dest_file = DEST_FOLDER + "/device_n_gradient_base.pdf";
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(dest_file, FileMode.Create));
            // step 3
            document.Open();
            // step 4
            PdfContentByte canvas = writer.DirectContent;
            PdfSpotColor psc_gray = new PdfSpotColor("iTextGray", new GrayColor(0f));
            PdfSpotColor psc_cmyk_yell = new PdfSpotColor("iTextYellow", new CMYKColor(0f, 0f, 1f, 0f));
            PdfSpotColor psc_cmyk_magen = new PdfSpotColor("iTextMagenta", new CMYKColor(0f, 1f, 0f, 0f));
            PdfSpotColor psc_rgb_blue = new PdfSpotColor("iTextBlue", new BaseColor(0, 0, 255));

            PdfDeviceNColor pdfDeviceNNChannelColor =
                new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue});
            PdfDeviceNColor pdfDeviceNNChannelColor2 =
                new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_magen, psc_cmyk_yell, psc_rgb_blue});

            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextGray", new GrayColor(0f)), 0.8f), 36, 824, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextYellow", new CMYKColor(0f, 0f, 1f, 0f)), 0.8f), 90, 824,
                36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextMagenta", new CMYKColor(0f, 1f, 0f, 0f)), 0.4f), 144, 824,
                36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextBlue", new BaseColor(0, 0, 255)), 0.7f), 198, 824, 36, 36);

            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue}),
                    new float[] {0, 0.0f, 1}), 36, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.1f, 0.1f, 1}), 90, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.2f, 0.2f, 1}), 144, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.3f, 0.3f, 1}), 198, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.4f, 0.4f, 1}), 252, 770, 36, 36);
            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue, psc_gray}),
                    new float[] {0.5f, 0.5f, 1, 0.5f}), 306, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor2, new float[] {0.6f, 0.1f, 1}), 360, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.7f, 0.7f, 1}), 416, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.8f, 0.8f, 1}), 470, 770, 36, 36);
            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue}),
                    new float[] {0.9f, 0.9f, 1}), 524, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 1}), 578, 770, 36, 36);

            PdfDeviceNColor pdfDeviceNColor = new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue});
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0, 0, 1}));
            canvas.Rectangle(36, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.1f, 0.1f, 1}));
            canvas.Rectangle(90, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.2f, 0.2f, 1}));
            canvas.Rectangle(144, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.3f, 0.3f, 1}));
            canvas.Rectangle(198, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.4f, 0.4f, 1}));
            canvas.Rectangle(252, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.5f, 0.5f, 1}));
            canvas.Rectangle(306, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.6f, 0.1f, 1}));
            canvas.Rectangle(360, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.7f, 0.7f, 1}));
            canvas.Rectangle(416, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.8f, 0.8f, 1}));
            canvas.Rectangle(470, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.9f, 0.9f, 1}));
            canvas.Rectangle(524, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {1, 1, 1}));
            canvas.Rectangle(578, 716, 36, 36);
            canvas.FillStroke();

            canvas.SaveState();
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Clip();
            canvas.NewPath();
            canvas.SaveState();
            canvas.ConcatCTM(329f, 0f, 0f, -329f, 89f, 506.5f);
            canvas.PaintShading(PdfShading.SimpleAxial(writer, 0, 0, 1, 0,
                new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 0}),
                new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0, 0, 1})));
            canvas.RestoreState();
            canvas.RestoreState();
            canvas.SetColorStroke(new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 1}));
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Stroke();

            // step 5
            document.Close();

            CompareTool compareTool = new CompareTool();
            String error = compareTool.Compare(dest_file, TEST_RESOURCES_PATH + "cmp_device_n_gradient_base.pdf", DEST_FOLDER, "diff_");
//.........这里部分代码省略.........
开发者ID:newlysoft,项目名称:itextsharp,代码行数:101,代码来源:DeviceNColorSpaceTest.cs


示例18: DeviceNCmykRedRgbBlueGradient

        public virtual void DeviceNCmykRedRgbBlueGradient() {
            Document document = new Document();
            // step 2
            String dest_file = DEST_FOLDER + "/device_n_gradient_CmykRedRgbBlue.pdf";
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(dest_file, FileMode.Create));
            // step 3
            document.Open();
            // step 4
            PdfContentByte canvas = writer.DirectContent;
            PdfSpotColor psc_red = new PdfSpotColor("Spot Red", new CMYKColor(0f, 1f, 1f, 0f));
            PdfSpotColor psc_blue = new PdfSpotColor("Spot Blue", new BaseColor(0, 0, 255));
            PdfDeviceNColor deviceNColor = new PdfDeviceNColor(new PdfSpotColor[] {psc_red, psc_blue});

            canvas.SaveState();
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Clip();
            canvas.NewPath();
            canvas.SaveState();
            canvas.ConcatCTM(329f, 0f, 0f, -329f, 89f, 506.5f);
            canvas.PaintShading(PdfShading.SimpleAxial(writer, 0, 0, 1, 0, new DeviceNColor(deviceNColor, new float[] {1, 0}),
                new DeviceNColor(deviceNColor, new float[] {0, 1})));
            canvas.RestoreState();
            canvas.RestoreState();
            canvas.SetCMYKColorStroke(0, 0, 0, 0xFF);
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Stroke();
            document.Close();

            CompareTool compareTool = new CompareTool();
            String error = compareTool.Compare(dest_file, TEST_RESOURCES_PATH + "cmp_device_n_gradient_CmykRedRgbBlue.pdf", DEST_FOLDER, "diff_");
            if (error != null) {
                Assert.Fail(error);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:34,代码来源:DeviceNColorSpaceTest.cs


示例19: NestedTableTest

        public virtual void NestedTableTest() {
            Document doc = new Document(PageSize.A4);
            String file = "nestedtabletest.pdf";
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(OUTPUT_FOLDER + file, FileMode.Create));
            doc.Open();

            ColumnText col = new ColumnText(writer.DirectContent);
            col.SetSimpleColumn(
                Utilities.MillimetersToPoints(25),
                Utilities.MillimetersToPoints(25),
                PageSize.A4.Right - Utilities.MillimetersToPoints(25),
                PageSize.A4.Top - Utilities.MillimetersToPoints(25));

            PdfPTable table = new PdfPTable(3);
            table.HeaderRows = 1;
            table.AddCell("H1");
            table.AddCell("H2");
            table.AddCell("H3");

            for (int i = 0; i < 15; i++) {
                PdfPCell cell = new PdfPCell(createNestedTable());
                cell.Rowspan = 3;
                cell.Colspan = 3;
                table.AddCell(cell);
            }
            col.AddElement(table);

            while (ColumnText.HasMoreText(col.Go())) {
                doc.NewPage();
                col.YLine = PageSize.A4.Top - Utilities.MillimetersToPoints(25);
            }

            doc.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:newlysoft,项目名称:itextsharp,代码行数:41,代码来源:RowspanTest.cs


示例20: RecursiveSmartMergeTest

        public void RecursiveSmartMergeTest() {
            string pathPrefix = @"PdfCopyTest/";
            string inputDocPath = @"recursiveSmartMerge.pdf";

            byte[]  part1 = ExtractPages(Path.Combine(RESOURCES, inputDocPath), 1, 2);
            string outputPath1 = Path.Combine(pathPrefix, "part1_c.pdf");
            File.WriteAllBytes(outputPath1, part1);

            byte[] part2 = ExtractPages(Path.Combine(RESOURCES, inputDocPath), 3,7);
            string outputPath2 = Path.Combine(pathPrefix, "part2_c.pdf");
            File.WriteAllBytes(outputPath2, part2);

            byte[] merged = Merge(new string[] {outputPath1, outputPath2});

            string mergedPath = Path.Combine(pathPrefix, "output_c.pdf");
            File.WriteAllBytes(mergedPath, merged);

            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(mergedPath, RESOURCES + "cmp_" + inputDocPath, "PdfCopyTest/" , "diff");
            if (errorMessage != null)
            {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:24,代码来源:PdfCopyTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompareType类代码示例发布时间:2022-05-24
下一篇:
C# CompareOptions类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap