How to add text and images to PDF in VB.NET with PDF.co Web API

This tutorial will show how to add text and images to PDF in VB.NET

These source code samples are listed and grouped by their programming language and functions they use. PDF.co Web API is the Rest API that provides set of data extraction functions, tools for documents manipulation, splitting and merging of pdf files. Includes built-in OCR, images recognition, can generate and read barcodes from images, scans and pdf. It can be used to add text and images to PDF using VB.NET.

This rich sample source code in VB.NET for PDF.co Web API includes the number of functions and options you should do calling the API to add text and images to PDF. In your VB.NET project or application you may simply copy & paste the code and then run your app! Detailed tutorials and documentation are available along with installed PDF.co Web API if you’d like to dive deeper into the topic and the details of the API.

Download free trial version of PDF.co Web API from our website with this and other source code samples for VB.NET.

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Module1.vb
      
Imports System.IO Imports System.Net Imports Newtonsoft.Json.Linq Module Module1 ' The authentication key (API Key). ' Get your own by registering at https://app.pdf.co/documentation/api Const API_KEY As String = "***********************************" ' Direct URL of source PDF file. Const SourceFileUrl As String = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-edit/sample.pdf" ' Comma-separated list of page indices (Or ranges) to process. Leave empty for all pages. Example '0,2-5,7-'. Const Pages As String = "" ' PDF document password. Leave empty for unprotected documents. Const Password As String = "" ' Destination PDF file name Const DestinationFile As String = ".\result.pdf" ' Text annotation params Private Const Type2 As String = "annotation" Private Const X2 As Int32 = 400 Private Const Y2 As Int32 = 600 Private Const Text As String = "APPROVED" Private Const FontName As String = "Times New Roman" Private Const FontSize As Decimal = 24 Private Const Color As String = "FF0000" Sub Main() ' Create standard .NET web client instance Dim webClient As WebClient = New WebClient() ' Set API Key webClient.Headers.Add("x-api-key", API_KEY) ' * Add text annotation * ' Prepare URL for `PDF Edit` API call Dim query As String = Uri.EscapeUriString(String.Format( "https://api.pdf.co/v1/pdf/edit/add?name={0}&password={1}&pages={2}&url={3}&type={4}&x={5}&y={6}&text={7}&fontname={8}&size={9}&color={10}", Path.GetFileName(DestinationFile), Password, Pages, SourceFileUrl, Type2, X2, Y2, Text, FontName, FontSize, Color)) Try ' Execute request Dim response As String = webClient.DownloadString(query) ' Parse JSON response Dim json As JObject = JObject.Parse(response) If json("error").ToObject(Of Boolean) = False Then ' Get URL of generated PDF file Dim resultFileUrl As String = json("url").ToString() ' Download PDF file webClient.DownloadFile(resultFileUrl, DestinationFile) Console.WriteLine("Generated PDF file saved as ""{0}"" file.", DestinationFile) Else Console.WriteLine(json("message").ToString()) End If Catch ex As WebException Console.WriteLine(ex.ToString()) End Try webClient.Dispose() Console.WriteLine() Console.WriteLine("Press any key...") Console.ReadKey() End Sub End Module

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

packages.config
      
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" /> </packages>

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Get PDF.co Web API Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Related Samples: