ScenePdfRenderer Class

Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) as PDF, as vector shapes and text.

public static class ScenePdfRenderer

Remarks

A source is laid out with the fonts that draw it (ScenePdfRenderer.CreateMeasurer), so its texts fit. Each text is drawn with the face of its family of the fonts of the scene (Scene.Fonts, then ScenePdfOptions.Fonts), and the PDF embeds the subsets of the faces it uses. Without fonts, the texts are drawn with the standard font Helvetica, which has the widths AfmTextMeasurer measures; the characters it cannot show are drawn as question marks.

The hyperlinks of the groups become link annotations of the page. The tooltips, the CSS classes and the data attributes are not drawn. A gradient whose stops have different opacities is drawn with their average opacity. PDF has no filters: a scene with a blur or a drop shadow (SceneElement.Filter) throws NotSupportedException.

Methods

NameDescription
CreateMeasurer(ScenePdfOptions?)Creates the text measurer of the fonts of the options, to lay a source out with ISceneSource.CreateScene.
DrawScene(PdfPage, ISceneSource, PdfPoint, ScenePdfOptions?)Lays a source out with the fonts of the options and draws it on a page.
DrawScene(PdfPage, Scene, PdfPoint, ScenePdfOptions?)Draws a scene on a page, over its content.
ToPdf(ISceneSource, ScenePdfOptions?)Lays a source out with the fonts of the options and draws it as a document of one page of its size times ScenePdfOptions.Scale.
ToPdf(Scene, ScenePdfOptions?)Draws a scene as a document of one page of its size times ScenePdfOptions.Scale. The title and the description of the scene are the title and the subject of the document. Unless ScenePdfOptions.Tagged is false, the document is tagged: its structure is a document whose figure is the drawing.

CreateMeasurer(ScenePdfOptions?)

ScenePdfRenderer.cs

Creates the text measurer of the fonts of the options, to lay a source out with ISceneSource.CreateScene.

public static ITextMeasurer CreateMeasurer(ScenePdfOptions? options = null)

Parameters

options ScenePdfOptions?
The options, or null for the defaults.

Returns

ITextMeasurer A FontFaceTextMeasurer of ScenePdfOptions.Fonts, or AfmTextMeasurer.Default, the metrics of Helvetica, without fonts.

DrawScene overloads

DrawScene(PdfPage, ISceneSource, PdfPoint, ScenePdfOptions?)

ScenePdfRenderer.cs

Lays a source out with the fonts of the options and draws it on a page.

public static PdfRectangle DrawScene(this PdfPage page, ISceneSource source, PdfPoint position, ScenePdfOptions? options = null)
Parameters
page PdfPage
The page.
source ISceneSource
The chart or the diagram.
position PdfPoint
The top-left corner of the drawing, in the coordinates of the page (the y axis points up).
options ScenePdfOptions?
The options, or null for the defaults.
Returns

PdfRectangle The rectangle the drawing covers.

Exceptions
NotSupportedException
An element has a filter (SceneElement.Filter): PDF has no filters. Nothing is drawn.

DrawScene(PdfPage, Scene, PdfPoint, ScenePdfOptions?)

ScenePdfRenderer.cs

Draws a scene on a page, over its content.

public static PdfRectangle DrawScene(this PdfPage page, Scene scene, PdfPoint position, ScenePdfOptions? options = null)
Parameters
page PdfPage
The page.
scene Scene
The scene, laid out with ScenePdfRenderer.CreateMeasurer so its texts fit.
position PdfPoint
The top-left corner of the drawing, in the coordinates of the page (the y axis points up).
options ScenePdfOptions?
The options, or null for the defaults.
Returns

PdfRectangle The rectangle the drawing covers.

Exceptions
ArgumentException
The position is not finite.
NotSupportedException
An element has a filter (SceneElement.Filter): PDF has no filters. Nothing is drawn.

ToPdf overloads

ToPdf(ISceneSource, ScenePdfOptions?)

ScenePdfRenderer.cs

Lays a source out with the fonts of the options and draws it as a document of one page of its size times ScenePdfOptions.Scale.

public static PdfDocument ToPdf(this ISceneSource source, ScenePdfOptions? options = null)
Parameters
source ISceneSource
The chart or the diagram.
options ScenePdfOptions?
The options, or null for the defaults.
Returns

PdfDocument The document. Save it with PdfDocument.Save.

Exceptions
ArgumentOutOfRangeException
The size of the scene is not a positive finite number.
NotSupportedException
An element has a filter (SceneElement.Filter): PDF has no filters.

ToPdf(Scene, ScenePdfOptions?)

ScenePdfRenderer.cs

Draws a scene as a document of one page of its size times ScenePdfOptions.Scale. The title and the description of the scene are the title and the subject of the document. Unless ScenePdfOptions.Tagged is false, the document is tagged: its structure is a document whose figure is the drawing.

public static PdfDocument ToPdf(this Scene scene, ScenePdfOptions? options = null)
Parameters
scene Scene
The scene, laid out with ScenePdfRenderer.CreateMeasurer so its texts fit.
options ScenePdfOptions?
The options, or null for the defaults.
Returns

PdfDocument The document. Save it with PdfDocument.Save.

Exceptions
ArgumentOutOfRangeException
The size of the scene is not a positive finite number.
NotSupportedException
An element has a filter (SceneElement.Filter): PDF has no filters. Nothing is drawn.