Module packages.printoptions

Print options for professional printers.

Requires: Inkscape and GraphicsMagick to be available on the host system.

Reminders: GraphicsMagick also needs Ghostscript for PDF images (it delegates to it).

Info:

  • Copyright: (c) 2022-2025 Omikhleia / Didier Willis
  • License: MIT

Local Functions

handlePath (filename) Handle path and extension of a filename.
imageResolutionConverter (filename, widthInPx, resolution, pageno) Convert an image to a target resolution.
svgRasterizer (filename, widthInPx, _) Rasterize a SVG vector image to a PNG.
drawSVG (filename, svgdata, width, height, density) Push a SVG image to the typesetter's hbox list, possibly rasterizing it.

Class packages.printoptions

package:_init (pkgoptions) (Constructor) Initialize the package.
package:declareSettings () (Override) Declare package-specific settings.


Local Functions

handlePath (filename)
Handle path and extension of a filename.

Parameters:

  • filename string Input filename

Returns:

  1. string Basename without extension
  2. string Extension with leading dot
imageResolutionConverter (filename, widthInPx, resolution, pageno)
Convert an image to a target resolution.

It uses GraphicsMagick to convert and resample the image.

Parameters:

  • filename string Input filename
  • widthInPx int Target width in pixels
  • resolution int Target resolution in DPI
  • pageno int Page number to extract (for PDF)

Returns:

    string or nil Converted filename, or nil on failure
svgRasterizer (filename, widthInPx, _)
Rasterize a SVG vector image to a PNG.

It uses Inkscape to convert the SVG to a PNG.

Parameters:

  • filename string Input filename
  • widthInPx int Target width in pixels
  • _ int Target resolution in DPI (currently unused for technical reasons)

Returns:

    string or nil Converted filename, or nil on failure
drawSVG (filename, svgdata, width, height, density)
Push a SVG image to the typesetter's hbox list, possibly rasterizing it.

Parameters:

  • filename string Input filename
  • svgdata string SVG data
  • width SILE.types.measurement or nil Target width (or nil)
  • height SILE.types.measurement or nil Target height (or nil)
  • density number SVG density (72 is considered 100%)

Raises:

If both width and height are provided (aspect ratio change not supported yet)

Class packages.printoptions

The "printoptions" package.
package:_init (pkgoptions)
(Constructor) Initialize the package.

It overrides the \svg command from the svg package to handle rasterization, and the outputter's image drawing method to handle image resampling.

Parameters:

  • pkgoptions table Package options
package:declareSettings ()
(Override) Declare package-specific settings.
generated by LDoc 1.5.0 Last updated 2025-09-14 22:28:52