Bienvenue

Jalios Community

Tout ce que vous souhaitez savoir sur l'écosystème Jalios

pdf2svg2.bat Script

Updated by Alain D'heygère · on 10/4/23 at 2:39 PM · Version 4.5
Uploaded by · on 7/22/15 at 4:57 PM
Command file (4.42 KB)

This script replaces 'pdf2svg.exe' which is still unstable despite our recompilation efforts.

It works by calling "pdfinfo.exe" then directly "pdftocairo.exe" on each page of the pdf to generate the svg version. These 2 programs are available in Poppler for Windows.

Here is the answer from the command line for the script pdf2svg2.bat :

*** Convert a pdf file in several svg files ***

This script needs 'pdfinfo' and 'pdftocairo' (poppler) in system path or to be edited to indicate their location.
It is originally written to match "Jalios Document Viewer Plugin" needs.

Usage : "pdf2svg2.bat" "Source-File" "Target-Dir" [-z]
 Source-File : Full path to pdf file to convert
 Target-Dir : Target directory where svg files will be written (one file per page)
       This directory must exist.
       (For compatibility reasons the Target-Dir attribute can end with 'content%d.svg' or 'content%d.svgz')
 -z : With this option output files will be named 'content%d.svgz' instead of 'content%d.svg'

Installation

  • Install Poppler for Windows (ex: "C:\tools\poppler\")
  • Install this script in poppler's  'bin' directory (ex: "C:\tools\poppler\bin\")
  • Add this directory in system path
  • Configure  (Restricted access link)  :
    • Enable SVG file generation
    • Enables SVG file compression
    • Command line of the pdf2svg executable :
      • C:\tools\poppler\bin\pdf2svg2.bat "{inputFile}" "{outputDirectory}" -z

It is possible to make variants to this installation mode, we propose the method that seems to us the simplest and most effective.

Note: Even if this script supports long paths and spaces in paths, we recommend your webapp installation to be done in a way such that upload directory is resolved with a short path and no space (ex: c:\jcms\upload\ or c:\tomcat\webapps\ROOT\upload\) to reduce any problems related to it, for this function and all others using the file system.

Exit codes

  • 0 : No error
  • 1 : [pdftocairo/pdfinfo] Error opening a PDF file
  • 2 : [pdftocairo/pdfinfo] Error opening an output file
  • 3 : [pdftocairo/pdfinfo] Error related to PDF permissions
  • 4 : [pdftocairo] Error related to ICC profile
  • 99 : [pdftocairo/pdfinfo] Other error
  • 200 : Source file not found
  • 201 : Target is not a directory or directory not found
  • 202 : pdfinfo couldn't run
  • 203 : pdftocairo couldn't run
  • 255 : Unknown error


On the same subject, see: