ScenePdfRenderer Class
Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) as PDF, as vector shapes and text.
public static class ScenePdfRendererRemarks
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
| Name | Description |
|---|---|
| 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.csCreates 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
optionsScenePdfOptions?- The options, or
nullfor 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.csLays 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
pagePdfPage- The page.
sourceISceneSource- The chart or the diagram.
positionPdfPoint- The top-left corner of the drawing, in the coordinates of the page (the y axis points up).
optionsScenePdfOptions?- The options, or
nullfor 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.csDraws a scene on a page, over its content.
public static PdfRectangle DrawScene(this PdfPage page, Scene scene, PdfPoint position, ScenePdfOptions? options = null)Parameters
pagePdfPage- The page.
sceneScene- The scene, laid out with
ScenePdfRenderer.CreateMeasurerso its texts fit. positionPdfPoint- The top-left corner of the drawing, in the coordinates of the page (the y axis points up).
optionsScenePdfOptions?- The options, or
nullfor 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.csLays 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
sourceISceneSource- The chart or the diagram.
optionsScenePdfOptions?- The options, or
nullfor 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.csDraws 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
sceneScene- The scene, laid out with
ScenePdfRenderer.CreateMeasurerso its texts fit. optionsScenePdfOptions?- The options, or
nullfor 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.