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)
# 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 }
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
@echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "& .\GeneratePdfInvoiceFromHtmlTemplate.ps1" echo Script finished with errorlevel=%errorlevel% pause
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