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

Write code in VB.NET to add text and images to PDF with this step-by-step tutorial

The sample source codes on this page shows how to add text and images to PDF in VB.NET. 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.

You will save a lot of time on writing and testing code as you may just take the VB.NET code from PDF.co Web API for add text and images to PDF below and use it in your application. In order to implement the functionality, you should copy and paste this code for VB.NET below into your code editor with your app, compile and run your application. Further enhancement of the code will make it more vigorous.

You can download free trial version of PDF.co Web API from our website to see and try many others 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" ' Image params Private Const Type1 As String = "image" Private Const X1 As Int32 = 400 Private Const Y1 As Int32 = 20 Private Const Width1 As Int32 = 119 Private Const Height1 As Int32 = 32 Private Const ImageUrl As String = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-edit/logo.png" 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 image * ' 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}&width={7}&height={8}&urlimage={9}", Path.GetFileName(DestinationFile), Password, Pages, SourceFileUrl, Type1, X1, Y1, Width1, Height1, ImageUrl)) 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: