|
| 1 | +using System; |
| 2 | +using System.IO; |
| 3 | +using iText.Kernel.Colors; |
| 4 | +using iText.Kernel.Geom; |
| 5 | +using iText.Kernel.Pdf; |
| 6 | +using iText.Kernel.Pdf.Canvas; |
| 7 | +using iText.Kernel.Utils; |
| 8 | +using iText.Test; |
| 9 | + |
| 10 | +namespace iText.PdfCleanup { |
| 11 | + [NUnit.Framework.Category("Integration test")] |
| 12 | + public class RectangleTest : ExtendedITextTest { |
| 13 | + private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext |
| 14 | + .CurrentContext.TestDirectory) + "/resources/itext/pdfcleanup/RectangleTest/"; |
| 15 | + |
| 16 | + private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory |
| 17 | + + "/test/itext/pdfcleanup/RectangleTest/"; |
| 18 | + |
| 19 | + [NUnit.Framework.OneTimeSetUp] |
| 20 | + public static void BeforeClass() { |
| 21 | + CreateDestinationFolder(DESTINATION_FOLDER); |
| 22 | + } |
| 23 | + |
| 24 | + [NUnit.Framework.Test] |
| 25 | + public virtual void ZeroWidthLineTest() { |
| 26 | + // TODO DEVSIX-7136 Rectangles drawn with zero-width line disappear on sweeping |
| 27 | + String outPdf = DESTINATION_FOLDER + "zeroWidthLine.pdf"; |
| 28 | + String cmpPdf = SOURCE_FOLDER + "cmp_zeroWidthLine.pdf"; |
| 29 | + MemoryStream outDocBaos = new MemoryStream(); |
| 30 | + using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outDocBaos))) { |
| 31 | + PdfPage page = pdfDocument.AddNewPage(); |
| 32 | + PdfCanvas canvas = new PdfCanvas(page); |
| 33 | + canvas.SetStrokeColor(DeviceRgb.BLUE).SetLineWidth(0).Rectangle(new Rectangle(350, 400, 100, 100)).Stroke( |
| 34 | + ); |
| 35 | + canvas.SetStrokeColor(DeviceRgb.RED).SetLineWidth(0).MoveTo(100, 100).LineTo(100, 200).LineTo(200, 200).LineTo |
| 36 | + (200, 100).ClosePath().Stroke(); |
| 37 | + } |
| 38 | + PdfDocument pdfDocument_1 = new PdfDocument(new PdfReader(new MemoryStream(outDocBaos.ToArray())), new PdfWriter |
| 39 | + (outPdf)); |
| 40 | + iText.PdfCleanup.PdfCleanUpTool workingTool = new iText.PdfCleanup.PdfCleanUpTool(pdfDocument_1); |
| 41 | + Rectangle area = new Rectangle(0, 50, 150, 150); |
| 42 | + workingTool.AddCleanupLocation(new iText.PdfCleanup.PdfCleanUpLocation(1, area, ColorConstants.RED)); |
| 43 | + workingTool.CleanUp(); |
| 44 | + pdfDocument_1.Close(); |
| 45 | + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_" |
| 46 | + )); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments