Writing of the code to generate PDF invoice from HTML template in VB.NET can be done by developers of any level using ByteScout Cloud API Server. HTML to PDF API in VB.NET can be applied with ByteScout Cloud API Server. ByteScout Cloud API Server is API server that is ready to use and can be installed and deployed in less than 30 minutes on your own Windows server or server in a cloud. It can save data and files on your local server-based file storage or in Amazon AWS S3 storage. Data is processed solely on the API server and is powered by ByteScout engine, no cloud services or Internet connection is required for data processing..
Use the code displayed below in your application to save a lot of time on writing and testing code. Open your VB.NET project and simply copy & paste the code and then run your app! Enjoy writing a code with ready-to-use sample VB.NET codes to add HTML to PDF API functions using ByteScout Cloud API Server in VB.NET.
Our website provides free trial version of ByteScout Cloud API Server that gives source code samples to assist with your VB.NET project.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Imports System.IO
Imports System.Net
Imports Newtonsoft.Json.Linq
' Please NOTE: In this sample we're assuming Cloud Api Server is hosted at "https://localhost".
' If it's not then please replace this with with your hosting url.
Module Module1
' HTML template
Dim template As String = File.ReadAllText(".\invoice_template.html")
' Data to fill the template
Dim templateData As String = File.ReadAllText(".\invoice_data.json")
' Destination PDF file name
Const DestinationFile As String = ".\result.pdf"
Sub Main()
' Create standard .NET web client instance
Dim webClient As WebClient = New WebClient()
Try
' Prepare URL for HTML to PDF API call
Dim request As String = Uri.EscapeUriString(String.Format(
"https://localhost/pdf/convert/from/html?name={0}",
Path.GetFileName(DestinationFile)))
' Prepare request body in JSON format
Dim jsonObject As JObject = New JObject(
New JProperty("html", template),
New JProperty("templateData", templateData))
webClient.Headers.Add("Content-Type", "application/json")
' Execute request
Dim response As String = webClient.UploadString(request, jsonObject.ToString())
' 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()
webClient.Headers.Remove("Content-Type") ' remove the header required for only the previous request
' Download the PDF file
webClient.DownloadFile(resultFileUrl, DestinationFile)
Console.WriteLine("Generated PDF document saved as ""{0}"" file.", DestinationFile)
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
60 Day Free Trial or Visit ByteScout Cloud API Server Home Page
Explore ByteScout Cloud API Server Documentation
Explore Samples
Sign Up for ByteScout Cloud API Server Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" />
</packages>
60 Day Free Trial or Visit ByteScout Cloud API Server Home Page
Explore ByteScout Cloud API Server Documentation
Explore Samples
Sign Up for ByteScout Cloud API Server Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Cloud API Server Home Page
Explore ByteScout Cloud API Server Documentation
Explore Samples
Sign Up for ByteScout Cloud API Server Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples