ByteScout Cloud API Server - HTML To PDF API - PowerShell - Generate PDF Invoice From HTML Template - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Cloud API Server – HTML To PDF API – PowerShell – Generate PDF Invoice From HTML Template

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

How to generate PDF invoice from HTML template for HTML to PDF API in PowerShell with ByteScout Cloud API Server

Follow this simple tutorial to learn generate PDF invoice from HTML template to have HTML to PDF API in PowerShell

These simple tutorials explain the code material for beginners and advanced programmers who are using PowerShell. HTML to PDF API in PowerShell 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..

Want to learn quickly? These fast application programming interfaces of ByteScout Cloud API Server for PowerShell plus the instruction and the code below will help to learn how to generate PDF invoice from HTML template. Open your PowerShell project and simply copy & paste the code and then run your app! Enjoy writing a code with ready-to-use sample PowerShell codes to add HTML to PDF API functions using ByteScout Cloud API Server in PowerShell.

Free! Free! Free! ByteScout free trial version is available for FREE download from our website. Programming tutorials along with source code samples are assembled.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

GeneratePdfInvoiceFromHtmlTemplate.ps1
      
# 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. # HTML template $Template = [IO.File]::ReadAllText(".\invoice_template.html") # Data to fill the template $TemplateData = [IO.File]::ReadAllText(".\invoice_data.json") # Destination PDF file name $DestinationFile = ".\result.pdf" # Prepare URL for HTML to PDF API call $query = "https://localhost/pdf/convert/from/html?name=$(Split-Path $DestinationFile -Leaf)" $query = [System.Uri]::EscapeUriString($query) # Prepare request body (will be auto-converted to JSON by Invoke-RestMethod) $body = @{ "html" = $Template "templateData" = $TemplateData } | ConvertTo-Json try { # Execute request $response = Invoke-WebRequest -Method Post -Headers @{ "Content-Type" = "application/json" } -Body $body -Uri $query if ($response.StatusCode -eq 200) { $jsonResponse = $response.Content | ConvertFrom-Json if ($jsonResponse.error -eq $false) { # Get URL of generated PDF file $resultFileUrl = $jsonResponse.url; # Download PDF file Invoke-WebRequest -OutFile $DestinationFile -Uri $resultFileUrl Write-Host "Generated PDF file saved as `"$($DestinationFile)`" file." } else { # Display service reported error Write-Host $jsonResponse.message } } else { # Display request error status Write-Host $response.StatusCode + " " + $response.StatusDescription } } catch { # Display request error Write-Host $_.Exception }

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

run.bat
      
@echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "& .\GeneratePdfInvoiceFromHtmlTemplate.ps1" echo Script finished with errorlevel=%errorlevel% pause

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