How to create pdf file from html
<html>
<head>
<title>LabCorp</title>
<link rel="apple-touch-icon" sizes="60x60" href="app-assets/img/ico/apple-icon-60.png">
<link rel="apple-touch-icon" sizes="76x76" href="app-assets/img/ico/apple-icon-76.png">
<link rel="apple-touch-icon" sizes="120x120" href="app-assets/img/ico/apple-icon-120.png">
<link rel="apple-touch-icon" sizes="152x152" href="app-assets/img/ico/apple-icon-152.png">
<link rel="shortcut icon" type="image/x-icon" href="app-assets/img/ico/favicon.ico">
<link rel="shortcut icon" type="image/png" href="app-assets/img/ico/favicon-32.png">
<style>
body, p, strong{font-size: 12px; font-family: Arial;}
table tr td{font-size: 12px; font-family: Arial; padding: 2px 6px;}
.borL{border-left:1px solid #333;}
.borR{border-right:1px solid #333;}
.borT{border-top:1px solid #333;}
.borB{border-bottom:1px solid #333;}
.border{border:1px solid #333;}
@font-face {
font-family: 'IDAutomationHC39M';
src: url('d:/file/fonts/IDAutomationHC39M_0.ttf');
}
.IDAutomationCover {
background: #f5f7fa;
/*margin-top: 14px;
padding-top: 45px;
padding-left: 10px;*/
padding-right: 10px;
}
.IDAutomationHC39M {
font-family: IDAutomationHC39M;
color: #525252;
font-size: 20px;
height: 80px;
line-height: 80px;
white-space: nowrap;
margin-bottom: 0;
padding-left: 10px;
padding-right: 10px;
}
svg {
border: 1px solid #000;
padding-bottom: 4px;
}
</style>
</head>
<body>
</body>
</html>
There are some open source tools available that convert HTML to PDF:
https://wkhtmltopdf.org/
Hi Marc,
Can you please provide an example that used wkhtmltopdf to covert html to pdf.
FYI,
I want to convert html to pdf programmatically.
The wkhtmltopdf website has an example of the command-line usage -- looks fairly simple.
And have a look at our product documentation for $ZF(-100) on how to execute an external program from ObjectScript.
Hi,
a sample:
set ok=$zf(-100,"",command)
on "html to pdf converter freeware" google gave me 3 270 000 hits.
Why reinventing the wheel.
Place your HTML into a local file and let someone else do the dirty job.
There are enough solutions for a call-out to trigger the conversion.
Use Pupeteer. Follow the third option tutorial and you should be fine.
P.S.: You need NodeJS to run Pupeteer.
Hi Vivek,
We bought a license for CoolUtils (coolutils.com), whch also has command line functionality. There are dozens of different converters with CoolUtils, but you can buy just the one.
We use a batch file for the command line, which will take two parameters, and an "option file" (used by the converter):
"C:\Program Files (x86)\TotalHTMLConverter\HTMLConverter.exe" "%1" "%2" -c pdf -fp -combine -si -pc Normal -ps letter -OptionFile %3
then call the batch file using $zf:
set command=dir_"Converters\html\ConvertHtmlToPDF.BAT"
set params(1)=fromHTMLfilename
set params(2)=toPDFfilename
set params(3)=OptionFileName
; NEXT: $ZF(-1) NOT USED BECAUSE ANY PROBLEM WITH THE CONVERTER PROGRAM WOULD CAUSE THIS PROCESS TO HANG UNTIL ETERNITY!!!
; Fire off HTML>PDF Converter program in background (-2 = don't wait)
s status=$ZF(-100,"/ASYNC",command,.params)
The OptionFile has PDF codes like:
po=Landscape
PgHead=&b&d &t
PgFoot=&bPage &p of &P&bInsights powered by RevenueHealth Systems (C) 2018
I used the utility's "Command Line Parameters" help file to figure out how to set all the options, and how to use the option file. I wrote a note to myself to "See http://www.verydoc.com/htmlprint-footer-header.html" for use on the pdf codes that are in the option file.
It took a while, and I had to program in a new "language" of PDF options and stuff.
Good luck!
Did you take a look into the embedded reporting solution?
https://cedocs.intersystems.com/latest/csp/docbook/Doc.View.cls?KEY=GRPT_report_running#GRPT_xslfo_pdf_config
There is an embedded built-in FOP
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue