text_templates::create_pdf_from_html (public)

 text_templates::create_pdf_from_html -html_content html_content

Defined in packages/acs-tcl/tcl/pdf-procs.tcl

The HTML Content is transformed into a PDF file

Switches:
-html_content
(required)
HTML Content that is transformed into PDF
Returns:
filename of the pdf file

Partial Call Graph (max 5 caller/called nodes):
%3 text_templates::create_pdf_content text_templates::create_pdf_content (public) text_templates::create_pdf_from_html text_templates::create_pdf_from_html text_templates::create_pdf_content->text_templates::create_pdf_from_html ad_file ad_file (public) text_templates::create_pdf_from_html->ad_file ad_tmpdir ad_tmpdir (public) text_templates::create_pdf_from_html->ad_tmpdir ad_try ad_try (public) text_templates::create_pdf_from_html->ad_try parameter::get parameter::get (public) text_templates::create_pdf_from_html->parameter::get util::which util::which (public) text_templates::create_pdf_from_html->util::which

Testcases:
No testcase defined.
Source code:
    
    set progname [parameter::get -parameter "HtmlDocBin" -default "htmldoc"]
    set htmldoc_bin [::util::which $progname]
    if {$htmldoc_bin eq ""} {
        error "text_templates::create_pdf_from_html: HTML converter 'progname' not found"
    }

    ad_try {
        set fp [file tempfile tmp_html_filename [ad_tmpdir]/pdf-XXXXXX.html]
        puts $fp $html_content
        close $fp

        # create pdf-file
        set tmp_pdf_filename "${tmp_html_filename}.pdf"
        exec $htmldoc_bin --webpage --quiet -t pdf -f $tmp_pdf_filename $tmp_html_filename

        # return the result file command was successful
        if {[ad_file exists $tmp_pdf_filename]} {
            return $tmp_pdf_filename
        }
        
    } on error {errorMsg} {
        ns_log Error "Error during conversion from html to pdf: $errorMsg"
    } finally {
        file delete -- $tmp_html_filename
    }
    return ""
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ]
Show another procedure: