QUESTIONS OR COMMENTS ABOUT PRODUCTS? WRITE US AT SUPPORT@BYTESCOUT.COM OR USE THIS FORM

How to add text to existing PDF document using Bytescout.PDF library for .NET applications

Add text to the existing PDF document using Bytescout.PDF library for .NET

In this example Bytescout.PDF library for .NET is used to add text to the first page of the existing PDF document (HelloWorld.pdf) and save new document as HelloWorldAgain.pdf

Download example source code: bytescoutpdf_example_add_text_to_existing_document.zip (6 KB)

Source PDF document which is taken as source to modify (add text) and save as new document file

PDF document with text added to the first page

            // Create main PDF Doc Engine

            
PDFDocEngine engine = new PDFDocEngine("""");



            
// Open existing document

            
Document document engine.AddDocument("HelloWorld.pdf");



            
// Get first page

            
Page page document.GetPage(0);



            
// Create new drawing

            
Drawing drawing page.AddDrawing();



            
// Add standard font

            
uint font document.AddFontStandard(StandardFontType.Courier, FontEncodingType.WinAnsi);



            
// Set Active Font

            
drawing.SetActiveFont(font, 50falsefalse);



            
// Draw Text

            
drawing.PlaceText(1001500"Hello again, World!");

            
drawing.PlaceText(1002000"(was added to the existing page)");



            
// Closing drawing on the page

            
drawing.Close();



            
// Save document

            
document.Save("HelloWorldAgain.pdf");


Download example source code: bytescoutpdf_example_add_text_to_existing_document.zip (6 KB)

Tutorials: