Jump to content

Recommended Posts

Posted

 

; #FUNCTION# ====================================================================================================================
; Name ..........: _html2pdf
; Description ...: Convert HTML file to PDF file with htm2pdf.exe by Synopse
; Syntax ........: _html2pdf($sHTML_FileFullPath[, $sPDF_FileFullPath = Default[, $bDeleteHTML = False]])
; Parameters ....: $sHTML_FileFullPath  - a string value. HTML file full path.
;                  $sPDF_FileFullPath   - [optional] a string value. Default value is Default -> $sHTML_FileFullPath & '.pdf'
;                  $bDeleteHTML         - [optional] a boolean value. Default is False.
; Return values .: $sPDF_FileFullPath or set @error to 1
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://blog.synopse.info/post/2010/07/14/htm2pdf-free-tool
; Example .......: No
; ===============================================================================================================================
Func _html2pdf($sHTML_FileFullPath, $sPDF_FileFullPath = Default, $bDeleteHTML = False)
    If $sPDF_FileFullPath = Default Then $sPDF_FileFullPath = $sHTML_FileFullPath & '.pdf'
    Local $sINI_FileFullPath = @ScriptDir & '\htm2pdf.ini'

    IniWrite($sINI_FileFullPath, 'Settings', 'HTML', $sHTML_FileFullPath)
    IniWrite($sINI_FileFullPath, 'Settings', 'PDF', $sPDF_FileFullPath)
    IniWrite($sINI_FileFullPath, 'Settings', 'OpenAfterSave', '0')
    IniWrite($sINI_FileFullPath, 'Settings', 'ScaleToFit', '1')
    IniWrite($sINI_FileFullPath, 'Settings', 'Orientation', 0)
    IniWrite($sINI_FileFullPath, 'Settings', 'PaperSize', 0)

    IniWrite($sINI_FileFullPath, 'Margins', 'Left', 2)
    IniWrite($sINI_FileFullPath, 'Margins', 'Top', 1)
    IniWrite($sINI_FileFullPath, 'Margins', 'Right', 1)
    IniWrite($sINI_FileFullPath, 'Margins', 'Bottom', 1)

    ShellExecuteWait(@ScriptDir & '\htm2pdf.exe', '/silent', @ScriptDir)
    If Not FileExists($sPDF_FileFullPath) Then
        Return SetError(1, 0, '')
    Else
        If $bDeleteHTML Then FileDelete($sHTML_FileFullPath)
        Return $sPDF_FileFullPath
    EndIf

EndFunc   ;==>_html2pdf

 

http://blog.synopse.info/post/2010/07/14/htm2pdf-free-tool#main

http://blog.synopse.info/post/2010/07/14/htm2pdf-free-tool

http://synopse.info/forum/viewtopic.php?pid=187

http://synopse.info/files/pdf/htm2pdf.zip

mLipok

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I'm Glad to hear that.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

This htm2pdf utility is much smaller than the 800-pound gorilla I normally use, wkhtmltopdf, which is around 16 MB in size... 

Though I feel I get more control over the output with wkhtmltopdf.

A smaller converter might become useful in the future!

Posted

:)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...