Module Vgr_pdf

module Vgr_pdf: sig .. end
Vg PDF renderer.

Renders a sequence of renderables as a multi-page PDF 1.7 document. Each renderable defines a page of the document.

Bug reports. PDF being an insane standard, rendering abilities of PDF readers vary wildly. No rendering bug report for this renderer will be considered if it cannot be reproduced in the latest Adobe Acrobat Reader.

v0.9.0 - homepage



Font resolution

Font resolution happens during the rendering of Vg.I.cut_glyphs images through the font callback given to the PDF rendering Vgr_pdf.target. See Text rendering for more details.

type otf_font 
The type for OpenType fonts.
val otf_font : string -> ([> `Otf of otf_font ], Otfm.error) Result.result
otf_font bytes is an OpenType font from the OpenType byte serialization bytes.
type font = [ `Courier
| `Fixed
| `Helvetica
| `Otf of otf_font
| `Sans
| `Serif
| `Times ]
The type for font resolution results. Any case different from `Otf ends up using the PDF standard fonts. See Text rendering for details.
val font : Vg.font -> font
font is the default font resolver. Given a Vg.font f it performs the following resolutions according to value of f.Font.name: See Text rendering for understanding what this entails.

PDF render targets


val target : ?font:(Vg.font -> font) ->
?xmp:string -> unit -> Vg.Vgr.dst_stored Vg.Vgr.target
target font xmp () is a PDF render target for rendering to the stored destination given to Vg.Vgr.create.

Multiple image. Multiple image render is supported. Each image defines a page of the resulting PDF file.


Text rendering

Text rendering depends on the way fonts are resolved by the function specified in the rendering Vgr_pdf.target. Given a glyph cut:

Vg.I.cut_glyphs ~text ~blocks ~advances font glyphs

First, if the optional text and blocks arguments are specified, they are always used to map the rendered glyphs to text for PDF text extraction. Then the following happens according to the resolution of the font argument by the render target:

So what should be used ? In general clients should use a font resolution mechanism independent from Vg in order to get an OpenType font otf for font. Using this otf font is should compute, using again a mechanism independent from Vg, a glyph layout resulting in advances and glyphs to use with Vg.I.cut_glyphs and finally resolve font in the target with `Otf otf. This means that font resolution should:



Render warnings and limitations

The following render warnings are reported.

The following limitations should be taken into account: