VB.NET PDF: How to HTML5 PDF Viewer PDF Create PDF Export File & Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer Work with Other SDKs Barcode Read Barcode Create OCR Twain
Text: Insert Text to PDF
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Insert Text to PDF

VB.NET PDF - Insert Text to PDF Document in VB.NET


Providing Demo Code for Adding and Inserting Text to PDF File Page in VB.NET Program




Multifunctional Visual Studio .NET PDF SDK library supports adding text content to adobe PDF document in VB.NET WinForms and ASP.NET


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Able to add a single text character and text string to PDF files in VB.NET


Insert formatted text and plain text to PDF page


Add text to certain position of PDF page in Visual Basic .NET class


Add text to PDF in preview without adobe reader component installed


Powerful .NET PDF edit control able to perform modification of existing scanned PDF file in VB.NET


Save text font, color, size and location changes to existing PDF file or output a new one


Other robust text processing features, like delete and remove PDF text, add PDF text box and field


Best freeware download for evaluation in .NET framework application


Access to online VB.NET class source codes


RasterEdge XDoc.PDF for .NET is a powerful PDF text processing control as well, which enables VB.NET users to add multiple text processing functions to PDF document imaging application, such as inserting text to PDF, deleting text from PDF, searching text in PDF, extracting text from PDF, and so on. On this tutorial page, we will demonstrate how to use VB.NET class code to add and insert text to PDF file page.


In general, developers can add text character and text string to a certain position of PDF document page. In the following parts, detailed VB.NET class demos are provided. Furthermore, if you are a Visual C# .NET programmer, you can go to this Visual C# tutorial for inserting text to PDF in .NET project.




DLLs for Insert Text to PDF in VB.NET



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;




VB.NET: Insert Text Character to PDF



This VB.NET example describes how to add a single text character to PDF document.




' Open a document.
Dim inputFilePath As String = Program.RootPath + "\\" + "1.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get a text manager from the document object
Dim textMgr As PDFTextMgr = PDFTextHandler.ExportPDFTextManager(doc)

' Set char value.
Dim aChar As Char = "A"

' Set text font.
Dim font As Font = New Font("Arial", 36.0F, FontStyle.Regular)

' Get the first page from the document.
Dim pageIndex As Integer = 0

' Move cursor to (400F, 100F).
Dim cursor As PointF = New PointF(400.0F, 100.0F)

' Add a character to the page.
textMgr.AddChar(aChar, font, pageIndex, cursor)

' Output the new document.
Dim outputFilePath As String = Program.RootPath + "\\" + "output.pdf"
doc.Save(outputFilePath)





VB.NET: Insert Text String to PDF



If you want to add a text string to PDF file, please try this demo for VB.NET.




' Open a document.
Dim inputFilePath As String = Program.RootPath + "\\" + "1.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Get a text manager from the document object.
Dim textMgr As PDFTextMgr = PDFTextHandler.ExportPDFTextManager(doc)

' Set string value.
Dim msg As String = "Hello World"

' Set text font.
Dim font As Font = New Font("Arial", 36.0F, FontStyle.Italic)

' Get the first page from the document.
Dim pageIndex As Integer = 0

' Move cursor to (400F, 100F).
Dim cursor As PointF = New PointF(400.0F, 100.0F)

' Set font color: red.
Dim fontColor As Color = Color.Red

' Add a string to the page.
textMgr.AddString(msg, font, pageIndex, cursor, fontColor)

' Output the new document.
Dim outputFilePath As String = Program.RootPath + "\\" + "output.pdf"
doc.Save(outputFilePath)