VB.NET PDF Text Library
How to add text to existing PDF file in vb.net Windows Forms application
Providing Demo Code for Adding and Inserting Text to PDF File Page in VB.NET Program
In this vb.net tutorial, you will learn how to add text to existing PDF file using VB.NET code in Visual Studio applications.
- Add, insert text to PDF
- Add text web link to PDF
- Add text annotations, comments to PDF
- Add text to PDF page header & footer
- Easy to develop in Windows Forms, WPF applications, ASP.NET using VB.NET
How to add text to existing PDF file using Visual Basic .NET
- 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.
display pdf in iframe mvc,
how to edit pdf file in asp.net c#,
pdf preview in asp net c# example,
asp.net c# pdf viewer control,
asp.net mvc open word document in browser,
asp net display image from file path,
asp net remove text from pdf javascript.
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.
Add text to PDF content using C#
With XDoc.PDF sdk, you can easily add, insert text chars, text string to pdf page with specified location, and text style format.
Add, insert text character to existing PDF document using VB.NET
This VB.NET coding example describes how to add a single text character to PDF document.
' open a document
Dim inputFilePath As String = "C:\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"c
' 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 = "C:\output.pdf"
doc.Save(outputFilePath)
Add, insert text String to existing PDF document using VB.NET
If you want to add a text string to PDF file, please try this vb.net demo.
Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\output.pdf"
' Open file
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)
' Save file
doc.Save(outputFilePath)
Add a hyperlink to PDF document using VB.NET
In PDF document, a hyperlink is linked with an area inside the PDF page. The following Visual Basic .NET example source code explains how to a link to a pdf page.
Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\output.pdf"
' Open file
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 = "Go to Google.com"
Dim hyperlink As String = "https://www.google.com"
' 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 (100F, 200F)
Dim cursor As PointF = New PointF(100.0F, 200.0F)
' Set font color: red
Dim fontColor As Color = Color.Red
' Add a string with hyperlink to the page
textMgr.AddHyperlink(msg, hyperlink, font, pageIndex, cursor, fontColor)
' Save file
doc.Save(outputFilePath)
VB.NET: add text object to PDF
Besides adding text to PDF content, you can also add text object to the PDF document, such as text annotation, text box annotation, text annotation at cursor.
Add textbox annotation in vb.net
If you want to add a textbox annotation to PDF file, please try this vb.net example source code.
Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "Annot_9.pdf"
' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get the 1st page
Dim page As PDFPage = doc.GetPage(0)
' create the annotation
Dim annot As PDFAnnotTextBox = New PDFAnnotTextBox()
annot.Boundary = New RectangleF(100.0F, 100.0F, 400.0F, 300.0F)
' add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot)
' save to a new file
doc.Save(outputFilePath)
VB.NET add text annotation
If you want to add a text annotation to PDF file, please try this vb.net example source code.
Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "Annot_11.pdf"
' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get the 1st page
Dim page As PDFPage = doc.GetPage(0)
' create the annotation
Dim annot As PDFAnnotText = New PDFAnnotText()
annot.Boundary = New RectangleF(400.0F, 500.0F, 300.0F, 80.0F)
annot.Content = "This is a text annotation"
' add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot)
' save to a new file
doc.Save(outputFilePath)
VB.NET add text annotation at cursor
If you want to add a text annotation at cursor to PDF file, please try this vb.net example source code.
Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "Annot_3.pdf"
' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get the 2nd page
Dim page As PDFPage = doc.GetPage(1)
' create the annotation
Dim annot As PDFAnnotHighlight = New PDFAnnotHighlight()
annot.StartPoint = New PointF(100.0F, 200.0F)
annot.EndPoint = New PointF(300.0F, 400.0F)
' add annotation to the page
page.AddPDFAnnot(annot)
' save to a new file
doc.Save(outputFilePath)
Add text to PDF page header and footer using VB.NET
If you need add text content to PDF page header and footer postion, please go to
How to add, edit PDF file page header, footer using vb.net for details