.NET API reference

The easiest way of getting started with PdfToSvg.NET is by installing the NuGet package.

PM> Install-Package PdfToSvg.NET

Open a PDF document by calling PdfDocument.Open(). Then use either SaveAsSvg() or ToSvgString() to save each page as SVG.

using (var doc = PdfDocument.Open("input.pdf"))
{
    var pageNo = 1;

    foreach (var page in doc.Pages)
    {
        page.SaveAsSvg($"output-{pageNo++}.svg");
    }
}

By default, PdfToSvg.NET will try to extract fonts embedded in the PDF and embed them in the output SVG as data URLs. This behavior can be changed by specifying another FontResolver.

Note
If you parse the XML returned from PdfToSvg.NET, you must preserve space and not add indentation. Otherwise text will not be rendered correctly in the modified markup.

Classes

DocumentInfoProvides information about a PDF document.
DocumentPermissionsProvides information about which operations to a PdfDocument that are allowed by the document author.
FileAttachmentProvides access to an embedded file attached to a PDF document.
FileAttachmentCollectionRead only collection of files attached to a PDF page.
FontRepresents a substitute font to be used in the generated SVG markup.
FontRepositoryContains fonts to be used if a PDF document refers to a non-embedded font.
FontResolverResolves which font to be used for text in the SVG, for a given PDF font name.
ImageProvides information about an image in a PDF document.
ImageEnumerableProvides access to images embedded in a PDF document.
ImageResolverResolves an image URL for an image encountered in a PDF document.
InlinedFontRepresents a font whose glyphs are inlined as paths and other elements within the SVG markup.
InvalidCredentialExceptionRepresents errors that occur when a document is password protected, but an incorrect password is specified or not specified at all.
LocalFontRepresents a font that is assumed to be installed on the machine viewing the SVG.
OpenOptionsProvides additional configuration options for opening a PdfDocument.
OptionalContentGroupRepresents an optional content group (OCG) in the PDF document. An optional content group can be seen as a layer, whose visibility can be controlled individually.
OptionalContentGroupCollectionContains a readonly collection of optional content groups from a PDF document.
PdfDocumentContains information about a loaded PDF file.
PdfExceptionRepresents errors that can occur while loading and converting a PDF file. This is the base class for all library specific exceptions.
PdfPageRepresents a single page in a PDF document.
PdfPageCollectionRead only collection of PdfPage objects.
PermissionExceptionRepresents errors that occurs when an attempt is made to perform an operation not allowed by the document author.
SourceFontContains information about a font used in the PDF document.
SvgConversionOptionsContains options affecting the behavior when a PDF page is converted to SVG.
WebFontUses a web font in the resulting SVG markup.

Enumerations

FontStyleSpecifies font styles.
FontWeightSpecifies font weights.