HTML2PDF-X Pilot – Sample program (VB Script)


Home       Download       Samples       Tutorials       Pricing       FAQ       History

 

HTML-to-PDF conversion with JavaScript

' Create HTML2PDF instance: 
Set html2pdf_obj = CreateObject("html2pdfx.HTML2PDFX") 
 
' Initiate engine: 
html2pdf_obj.StartHTMLEngine "demo", "demo" 
 
' Set PDF filename: 
html2pdf_obj.OutputFileName = "JavaScript_sample.pdf" 
 
' Set page margins: 
html2pdf_obj.MarginLeft = 40 
html2pdf_obj.MarginRight = 40 
html2pdf_obj.MarginTop = 30 
html2pdf_obj.MarginBottom = 50 
 
html2pdf_obj.DocumentTitle = "Example of using JavaScript" 
 
html2pdf_obj.BeginDoc
 
' Rescale content to fit page: 
html2pdf_obj.ContentZoomFactor = 70 
 
' Define base URL for resolving relative links: 
html2pdf_obj.BaseURL = "https://www.colorpilot.com/" 
 
' Load URL: 
html2pdf_obj.LoadURL "https://www.colorpilot.com/support" 
 
html2pdf_obj.RunJavaScript "document.getElementsByName('name')[0].value = 'John Watson';" &_ 
"document.getElementsByName('email')[0].value = 'john@watson.com';" &_ 
"document.getElementsByName('idorder')[0].value = '1234567890';" &_ 
"document.getElementsByName('message')[0].value = 'I have a question...';" &_ 
"document.getElementsByName('product')[0].selectedIndex = 30;" &_ 
"document.getElementsByName('os')[0].selectedIndex = 1;" 
 
' Perform conversion: 
html2pdf_obj.ConvertAll 
 
' Draw supporting text and figures: 
html2pdf_obj.FillingColor = "transparent" 
html2pdf_obj.PenColor = "red" 
html2pdf_obj.PenWidth = 4 
html2pdf_obj.DrawRoundedRect 70, 280, 255, 95, 10, 10, 0 
html2pdf_obj.PenColor = "blue" 
html2pdf_obj.FontPointSize = 9 
html2pdf_obj.DrawText 340, 320, 400, 200, "alignleft aligntop", "HTML2PDF-X has filled this form", 1, 1, 0 
 
html2pdf_obj.EndDoc 
 
Set html2pdf_obj = nothing
 
CreateObject("WScript.Shell").Run "JavaScript_sample.pdf"

 

– HTML2PDF-X Pilot sample page –

 


Home       Download       Samples       Tutorials       Pricing       FAQ       History