On this Page

    PDF Page Images

    (As of 3.1.002.01)

    You are now able to reference a page of a PDF file as an image. The syntax is as follows:

    path/fileName.pdf?page=3&dpi=150

    The default value for page is 1, and the default dpi is 150.

    This functionality relies on the existence of 3rd party software which you must download and install on your own. This functionality will not work until you do so. Considerable flexibility is built-in to allow you to choose your desired 3rd party software. See Default-PDF2PNG.wjs below.

    Default-PDF2PNG.wjs

    To support the PDF-Page-as-an-Image feature, Merge (and Design) run a supplied script, named: "Default-PDF2PNG.wjs". Naturally, that is in the DO/Bin ($E) folder. You may override that script by copying and revising it in file User/Overrides/PDF2PNG.wjs. Merge will choose that override file if it exists.

    If you look in that script file you will see that by default we have chosen to use the pdftopng.exe tool that is available from Xpdf (https://www.xpdfreader.com/ -- you would want the xpdf tools). If you override the script you may choose other such software tools. There appears to be a myriad set available.

    To run that script Merge uses the RunScript program as follows:

    RunScript -script [...]PDF2PNG.wjs -in="pdf spec provided" -out="a temp file for the png"

    The script is pretty small. It parses the supplied pdf spec to determine the pdf file name, the desired page number, and the desired DPI (with defaults). It then runs $P/pdftopng.exe with its needed parameters. Of course, your override script might run something else and indeed might look for other options on the pdf spec (what I would call a 'query string'). The end result of whatever you run must produce an image file in the supplied -out file. pdftopng.exe does that quite nicely. (As it happens, pdftopng produces a file name of its own choosing but our script renames that to the demanded -out file name.)

    $P?? What's that? $P was also introduced in 3.1.002.01 as a means to specify a semicolon-separated list (path) of folders to search to find the base file name. Since we do not distribute these 3rd party files we do not know where you will install them. By defining $P, typically in your $O/Paths.prm file, you can specify a path for DO software to use to look for files.

    Alternatively, you could put pdftopng directly in the $E (DO/Bin) folder. We recommend that you do not put additional software in $E as future updates may cause it to be deleted.

    Since the script is totally open, you can do whatever you want. Use whatever tools you want, and handle whatever file types you want. Just pay attention to the -in and the -out parameters supplied by Merge and you're good to go.

    See Also

    $X String Substitutions
    JSON Data Files