Horje
how to convert c# string to pdf Code Example
how to convert c# string to pdf
//Create a new PDF documentPdfDocument document = new PdfDocument();//Add a page to the documentPdfPage page = document.Pages.Add();//Create PDF graphics for the pagePdfGraphics graphics = page.Graphics;//set the standard fontPdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);//Read the text from the text fileStreamReader reader = new StreamReader("input.txt", Encoding.ASCII);string text = reader.ReadToEnd();reader.Close();//Set the formats for the textPdfStringFormat format = new PdfStringFormat();format.Alignment = PdfTextAlignment.Justify;format.LineAlignment = PdfVerticalAlignment.Top;format.ParagraphIndent = 15f;//Draw the textgraphics.DrawString(text, font, PdfBrushes.Black, new RectangleF(new PointF(0,0), page.GetClientSize()), format);//Save the documentdocument.Save("OutputText.pdf");//Close the documentdocument.Close(true);//This will open the PDF file so, the result will be seen in default PDF viewerProcess.Start("OutputText.pdf");Copy




Csharp

Related
linear search algorithm c# Code Example linear search algorithm c# Code Example
unity time of day Code Example unity time of day Code Example
string.insert c# Code Example string.insert c# Code Example
if statement in razor using "?" and ":" Code Example if statement in razor using "?" and ":" Code Example
c# square symbol Code Example c# square symbol Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14