ByteScout Cloud API Server - HTML To PDF API - VB.NET - Generate PDF Invoice From HTML Template - ByteScout

ByteScout Cloud API Server – HTML To PDF API – VB.NET – Generate PDF Invoice From HTML Template

  • Home
  • /
  • Articles
  • /
  • ByteScout Cloud API Server – HTML To PDF API – VB.NET – Generate PDF Invoice From HTML Template

How to generate PDF invoice from HTML template for HTML to PDF API in VB.NET using ByteScout Cloud API Server

Follow this simple tutorial to learn generate PDF invoice from HTML template to have HTML to PDF API in VB.NET

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)

Module1.vb
      
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

ON-PREMISE OFFLINE SDK

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

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

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

ON-PREMISE OFFLINE SDK

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

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

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

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next