PdfPage.ToSvgString Method

Converts this page to an SVG string. The string can for example be saved to a file, or inlined in HTML.

public string ToSvgString(
	SvgConversionOptions? options = null,
	CancellationToken cancellationToken = default
)
Namespace
PdfToSvg
Package
PdfToSvg.NET (since v0.2.0)

Parameters

options  SvgConversionOptions  (Optional)
Additional configuration options for the conversion.
cancellationToken  CancellationToken  (Optional)
Token for monitoring cancellation requests.

Return Value

String
SVG fragment without XML declaration. The fragment can be saved to a file or included as inline SVG in HTML.

Exceptions

ExceptionCondition
PermissionExceptionContent extraction from this document is forbidden by the document author. Not thrown if the document is opened with the owner password.
PdfExceptionThe conversion failed, possibly because of a malformed PDF.

Remarks

Note that if you parse the returned SVG fragment as XML, you need to preserve space and not add indentation. Text content will otherwise not render correctly.

See Also

PdfPage Class
PdfToSvg Namespace