Back to Devexpress

PdfDocumentProcessor.CreateSvgImage(Int32, PdfPageRenderingParameters) Method

officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-createsvgimage-x28-system-dot-int32-devexpress-dot-pdf-dot-pdfpagerenderingparameters-x29.md

latest4.8 KB
Original Source

PdfDocumentProcessor.CreateSvgImage(Int32, PdfPageRenderingParameters) Method

Exports a PDF page as an SVG image.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public DXSvgImage CreateSvgImage(
    int pageNumber,
    PdfPageRenderingParameters parameters
)
vb
Public Function CreateSvgImage(
    pageNumber As Integer,
    parameters As PdfPageRenderingParameters
) As DXSvgImage

Parameters

NameTypeDescription
pageNumberInt32

The page number.

| | parameters | PdfPageRenderingParameters |

An object that contains page rendering parameters.

|

Returns

TypeDescription
DXSvgImage

The converted page.

|

Remarks

This CreateBitmap method overload allows you to specify a DPI for an exported SVG image. Call the PdfPageRenderingParameters.CreateWithResolution(Single) method to create a new PdfPageRenderingParameters instance with the specified image DPI and pass it as the CreateSvgImage method parameter.

The following code snippet exports each page in a PDF as SVG images:

csharp
using DevExpress.Drawing;
using DevExpress.Pdf;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument(@"Docs//Document.pdf");

    for (int i = 1; i <= processor.Document.Pages.Count; i++)
    {
        PdfPageRenderingParameters renderingParameters = PdfPageRenderingParameters.CreateWithResolution(72f);
        // Export pages to SVGs
        DXImage image = processor.CreateSvgImage(i, renderingParameters);

        using (var fileStream = File.Create("..\\..\\MySvg" + i + ".svg"))
        {
            // Save the images
            image.Save(fileStream, DXImageFormat.Svg);
        }
    }
}
vb
Imports DevExpress.Drawing
Imports DevExpress.Pdf

Using processor As New PdfDocumentProcessor()
  ' Load a document
  processor.LoadDocument("Docs//Document.pdf")

  For i As Integer = 1 To processor.Document.Pages.Count
    Dim renderingParameters As PdfPageRenderingParameters = PdfPageRenderingParameters.CreateWithResolution(72F)
    ' Export pages to SVGs
    Dim image As DXImage = processor.CreateSvgImage(i, renderingParameters)

    Using fileStream = File.Create("..\..\MySvg" & i & ".svg")
      ' Save the images
      image.Save(fileStream, DXImageFormat.Svg)
    End Using
  Next i
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateSvgImage(Int32, PdfPageRenderingParameters) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

pdf-document-api-export-document-to-multi-page-tiff-and-bitmap/CS/ExportToImage/Program.cs#L37

csharp
// Export pages to SVGs
DXImage svgImage = processor.CreateSvgImage(pageNumbers[0], renderingParameters);

pdf-document-api-export-document-to-multi-page-tiff-and-bitmap/VB/ExportToImage/Program.vb#L27

vb
' Export pages to SVGs
Dim svgImage As DXImage = processor.CreateSvgImage(pageNumbers(0), renderingParameters)
' Save the images

See Also

PdfDocumentProcessor Class

PdfDocumentProcessor Members

DevExpress.Pdf Namespace