Skip to content

Commit a27d445

Browse files
committed
989885-ug: Resolved Given feedback.
1 parent c760b6b commit a27d445

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Document-Processing/PDF/PDF-Library/NET/Working-with-Text.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,30 @@ document.Close(True)
386386

387387
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text/Draw-text-in-PDF-document-using-standard-fonts/).
388388

389-
### Draw text using TrueType fonts
389+
### Draw Text using TrueType fonts
390390

391-
You can add text using the TrueType fonts installed in the system, by initializing [PdfFont](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfFont.html) class as [PdfTrueTypeFont](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfTrueTypeFont.html) class. The following code snippet illustrates this.
391+
You can add text using TrueType fonts either installed on the system or provided as a font stream by initializing the [PdfFont](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfFont.html) class as a [PdfTrueTypeFont](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfTrueTypeFont.html). The following code Example demonstrates this approach.
392392

393393
{% tabs %}
394394

395395
{% highlight c# tabtitle="C# [Cross-platform]" %}
396396

397-
//The code uses `System.Drawing.Font`, which is `not cross-platform` and works only on Windows due to its dependency on GDI+
397+
//Create a new PDF document.
398+
PdfDocument document = new PdfDocument();
399+
//Add a page to the document.
400+
PdfPage page = document.Pages.Add();
401+
402+
//Create PDF graphics for the page.
403+
PdfGraphics graphics = page.Graphics;
404+
//Provide the path of the local *.ttf file
405+
PdfFont font = new PdfTrueTypeFont(new Font("Arial.ttf", 14));
406+
//Draw the text.
407+
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
408+
409+
//Save the document.
410+
document.Save("Output.pdf");
411+
//Close the document.
412+
document.Close(true);
398413

399414
{% endhighlight %}
400415

0 commit comments

Comments
 (0)