GithubHelp home page GithubHelp logo

4d-plugin-htmltox's Introduction

4d-plugin-HTMLTOX

4D implementation of wkhtmltopdf

Deprecated! Use 4d-component-wkhtmltopdf instead.

Platform

carbon cocoa win32 win64

Version

Based on wkhtmltopdf 0.12.2.3.

Syntax

document:=HTML Convert(sources;format;optionNames;optionValues)
Parameter Type Description
sources ARRAY TEXT URL (http:, https:, ftp:, file:), path, HTML
format LONGINT HTMLTOX Format PDF, HTMLTOX Format PS, HTMLTOX Format PNG, HTMLTOX Format JPG, HTMLTOX Format BMP. HTMLTOX Format SVG
optionNames ARRAY TEXT http://wkhtmltopdf.org/libwkhtmltox/
optionValues ARRAY TEXT http://wkhtmltopdf.org/libwkhtmltox/
document BLOB PDF or image

Quick Download

Mac-0.12.4 font size is about 25% but the program can process unicode paths

Mac+Windows-MinGW

Mac+Windows-VC

Examples

  • HTML to PDF
$path:=Get 4D folder(Database folder)+\
"Plugins"+Folder separator+\
"HTMLTOX.bundle"+Folder separator+\
"Contents"+Folder separator+\
"Resources"+Folder separator+\
"Documentation"+Folder separator+\
"index.html"

  //3 ways to provide source
ARRAY TEXT($html;3)
$html{1}:="http://wkhtmltopdf.org/"  //a: URL
$html{2}:=Document to text($path)  //b: HTML source code
$html{3}:=$path  //c: path of HTML

  //for full list of keys, see http://wkhtmltopdf.org/libwkhtmltox/
ARRAY TEXT($optionKeys;0)
ARRAY TEXT($optionValues;0)
  //special consideration: for per-object (page) settings, 
  //prefix the key with an element number corresponding to the array of htmls.
  //e.g. "size.paperSize" this is a global setting
  //"1:toc.useDottedLines" this is a per-object setting for $html{1}

APPEND TO ARRAY($optionKeys;"size.paperSize")
APPEND TO ARRAY($optionValues;"A4")

APPEND TO ARRAY($optionKeys;"orientation")
APPEND TO ARRAY($optionValues;"Landscape")

$resultBlob:=HTML Convert ($html;HTMLTOX Format PDF;$optionKeys;$optionValues)

$path:=Temporary folder+Generate UUID+".pdf"

BLOB TO DOCUMENT($path;$resultBlob)

OPEN WEB URL($path)
  • HTML to PNG, BMP, JPG, SVG
ARRAY TEXT($html;1)  //only the first element is used for image
$html{1}:="http://wkhtmltopdf.org/"

  //for full list of keys, see http://wkhtmltopdf.org/libwkhtmltox/
ARRAY TEXT($optionKeys;0)
ARRAY TEXT($optionValues;0)

$resultBlob:=HTML Convert ($html;HTMLTOX Format PNG;$optionKeys;$optionValues)
$path:=Temporary folder+Generate UUID+".png"
BLOB TO DOCUMENT($path;$resultBlob)
OPEN URL($path)

$resultBlob:=HTML Convert ($html;HTMLTOX Format SVG;$optionKeys;$optionValues)
$path:=Temporary folder+Generate UUID+".svg"
BLOB TO DOCUMENT($path;$resultBlob)
OPEN URL($path)

$resultBlob:=HTML Convert ($html;HTMLTOX Format BMP;$optionKeys;$optionValues)
$path:=Temporary folder+Generate UUID+".bmp"
BLOB TO DOCUMENT($path;$resultBlob)
OPEN URL($path)

$resultBlob:=HTML Convert ($html;HTMLTOX Format JPG;$optionKeys;$optionValues)
$path:=Temporary folder+Generate UUID+".jpg"
BLOB TO DOCUMENT($path;$resultBlob)
OPEN URL($path)

To set per-page option, prepend the option name by its source number (1-based).

The plugin processes the source array from element number 0, so to specify an option for a single source.

ARRAY TEXT($optionKeys;0)
ARRAY TEXT($optionValues;0)

ARRAY TEXT($html;1)
$html{1}:=System folder(Desktop)+"source.html"

APPEND TO ARRAY($optionKeys;"1:web.printMediaType")
APPEND TO ARRAY($optionValues;"true")

$resultBlob:=HTML Convert ($html;HTMLTOX Format PDF;$optionKeys;$optionValues)
$dstPath:=Temporary folder+Generate UUID+".pdf"
BLOB TO DOCUMENT($dstPath;$resultBlob)
OPEN URL($dstPath)

History

v3.0

Callback feature is deprecated.

You can pass file path, URL or raw HTML as source.

The helper app is launched per process and stays running for the lifetime of that process.

libwkhtmltox is no longer linked as a dylib; instead, a command line program is invoked internally.

TODO: Check caller process ID so that multiple instances of 4D can use the plugin. done in 3.0

Remarks

When used on a Mac client connected to Windows server, the executable bit of the helper app may be lost. You might need to use chmod locally on the helper app's executable file.

The plugin now changes the bits internally.

4d-plugin-htmltox's People

Contributors

miyako avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

4d-plugin-htmltox's Issues

Not working

Hi.
Just tried the HTMLTOX.4dbase but not working for me. The result blob is 0 octets.
Is there some settings or environment to test with ?

Thanks

Freeze in v17 MacOS

process constantly freeze with HTML Convert command with v17, it works in v16

Trouble with 4D web server

Hi,

I use HTMLTOX in a website to create PDF of a page of my website, during the process (± 20s), all web requests are not treated by 4D. All arrives when HTMLTOX finished... A way to avoid this behavior ? it could be 400 waiting sometime...

thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.