Print a HTML string to PDF: Difference between revisions
From DataFlex Wiki
Jump to navigationJump to search
Extract of recent forum discussion |
m add syntax highlighting |
||
Line 8: | Line 8: | ||
Following is a DataFlex function that returns the full path for the exe-file (once it has been installed on the machine). | Following is a DataFlex function that returns the full path for the exe-file (once it has been installed on the machine). | ||
<source lng="dataflex"> | |||
// Return full path to "wkhtmltopdf.exe" | // Return full path to "wkhtmltopdf.exe" | ||
Function HtmlToPdfExeFile Returns String | Function HtmlToPdfExeFile Returns String | ||
Line 27: | Line 28: | ||
Function_Return sExeFile | Function_Return sExeFile | ||
End_Function | End_Function | ||
</source> | |||
==External Links== | ==External Links== |
Revision as of 23:40, 22 February 2019
Say you have a cwebHTMLEdit and you want to print the HTML result to a PDF file with a fixed name and destination.
You can do it via: "wkhtmltopdf" (WebKit HTML to PDF)
You can find the tool on this page: https://wkhtmltopdf.org/index.html
Following is a DataFlex function that returns the full path for the exe-file (once it has been installed on the machine).
// Return full path to "wkhtmltopdf.exe" Function HtmlToPdfExeFile Returns String Integer hoRegistry Boolean bFound String sExeFile sKey Get Create (RefClass(cRegistry)) to hoRegistry Set phRootKey of hoRegistry to HKEY_LOCAL_MACHINE Set pfAccessRights of hoRegistry to (Key_Read ior wkKEY_WOW64_64KEY) Get OpenKey of hoRegistry "SOFTWARE\wkhtmltopdf" to bFound If (bFound) Begin If (ValueExists(hoRegistry,"PdfPath")) Begin Get ReadString of hoRegistry "PdfPath" to sExeFile End Send CloseKey of hoRegistry End Send Destroy of hoRegistry Function_Return sExeFile End_Function
External Links
This know how comes from: https://support.dataaccess.com/Forums/showthread.php?62055-Printing-a-HTML-string-to-PDF-file