From 9bae91308b1914d9979bcbe2350c50be3667d5a5 Mon Sep 17 00:00:00 2001 From: Srihariharan Date: Wed, 14 Aug 2024 17:31:34 +0530 Subject: [PATCH] 898998: update the github sample. --- .../.NET/Line_limit_in_PDF/Program.cs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Text/Line-limit-in-PDF/.NET/Line_limit_in_PDF/Program.cs b/Text/Line-limit-in-PDF/.NET/Line_limit_in_PDF/Program.cs index 76592d26..88ecd393 100644 --- a/Text/Line-limit-in-PDF/.NET/Line_limit_in_PDF/Program.cs +++ b/Text/Line-limit-in-PDF/.NET/Line_limit_in_PDF/Program.cs @@ -2,34 +2,33 @@ using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; -// Define a multi-line string -string text = @"PdfStringFormat 1 -PdfStringFormat 2 -PdfStringFormat 3 -PdfStringFormat 4 -PdfStringFormat 5 -"; - // Create a new PdfStringFormat and set its properties PdfStringFormat format = new PdfStringFormat(); -format.ClipPath = true; -format.NoClip = false; +//Set no clip +format.NoClip = true; +//Set line limit format.LineLimit = false; -// Create a new PdfFont using the Helvetica font family and size 12 +// Create a new PdfFont using the Helvetica font family PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + // Create a new PdfDocument PdfDocument document = new PdfDocument(); // Set the page margins to zero document.PageSettings.Margins.All = 0; + // Add a new page to the document PdfPage page = document.Pages.Add(); + // Get the graphics object of the page PdfGraphics graphics = page.Graphics; + // Draw a red rectangle at the specified position and size graphics.DrawRectangle(PdfPens.Red, new RectangleF(100, 100, 100, 20)); + // Draw the string inside the rectangle with the specified font, brush, and format -graphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(100, 100, 100, 20), format); +graphics.DrawString("PDF text line 1 \r\nPDF text line 3", font, PdfBrushes.Black, new RectangleF(100, 100, 100, 20), format); + // Create a memory stream to save the PDF document MemoryStream stream = new MemoryStream(); // Save the document to the memory stream