Class SvgSaveOptions

SvgSaveOptions class

Save options for export to SVG format

public class SvgSaveOptions : UnifiedSaveOptions


SvgSaveOptions()The default constructor.


CloseResponse { get; set; }Gets or sets boolean value which indicates will Response object be closed after document saved into response.
ExtractOcrSublayerOnly { get; set; }This atrribute turned on functionality for extracting image or text for PDF documents with OCR sublayer.
SaveFormat { get; }Format of data save.
WarningHandler { get; set; }Callback to handle any warnings generated. The WarningHandler returns ReturnAction enum item specifying either Continue or Abort. Continue is the default action and the Save operation continues, however the user may also return Abort in which case the Save operation should cease.


CompressOutputToZipArchiveSpecifies whether output will be created as one zip-archive. Please refer comment to ‘TreatTargetFileNameAsDirectory’ options to see rules of naming of svg-files of pages for multipage source document, that are also applied to zipped set of output files.
CustomStrategyOfEmbeddedImagesSavingThis field can contain saving strategy that must be used (if present) during conversion for customized handling of created referenced external images files (like embedded BMP or JPEG) embedded into saved SVG. That strategy must process resources and return string that represents desirable URI of saved resource in generated SVG. If processing for this or that file for some reason must be done by converter’s code itself, not in custom code, please set in custom code flag ‘CustomProcessingCancelled’ of ‘imageSavingInfo’ parameter’s variable It signals to converter that all the necessary steps for processing of that resource must be done in converter itself as if there was no any external custom code .
ScaleToPixelsSpecifies whether to scale the output document from typographic points to pixels.
TreatTargetFileNameAsDirectoryThis options defines whether will be created target directory (if absent yet) with same name as requested output file instead of requested output file itself. It so, that directory will contain all output SVG-images of pages (like described below). If no, output files of pages other then first one will be created exactly in requested directory as main output file, but will contain in file name suffix _[2…n], that is defined by page number, f.e. if You define output file “C:\AsposeTests\output.svg” and output will contain several svg-files of pages, then files of pages will be created also in directory “C:\AsposeTests" and have names ‘output.svg’, ‘output_2.svg’, ‘output_3.svg’ etc.
TryMergeAdjacentSameBackgroundImagesSometimes PDFs contain background images (of pages or table cells) constructed from several same tiling background images put one near other. In such case renderers of target formats (f.e MsWord for DOCS format) sometimes generates visible boundaries beetween parts of background images, cause their techniques of image edge smoothing (anti-aliasing) is different from Acrobat Reader. If it looks like exported document contains such visible boundaries between parts of same background images, please try use this setting to get rid of that unwanted effect. ATTENTION! This optimization of quality usually essentially slows down conversion, so, please, use this option only when it’s really necessary.


The following example shows how to convert PDF file to SVG file

	// The path to the documents directory.
	string dataDir = "YOUR_DATA_DIRECTORY";

	// The path to your PDF File.
	var pdfFile = Path.Combine(dataDir, "PDF-to-SVG.pdf");

	// The path to output SVG File.
	var svgFile= Path.Combine(dataDir, "PDF-to-SVG.svg");
	using (Document pdfDocument = new Document(pdfFile))
		// Initialize SvgSaveOptions	
		SvgSaveOptions saveOptions = new SvgSaveOptions();
		// Save SVG file
		pdfDocument.Save(svgFile, saveOptions);

    ' The path to the documents directory.
    Dim dataDir As String = "YOUR_DATA_DIRECTORY"

    ' The path to your PDF File.
    Dim pdfFile = Path.Combine(dataDir, "PDF-to-SVG.pdf")

    ' The path to output SVG File.
    Dim svgFile = Path.Combine(dataDir, "PDF-to-SVG.svg")
    Using pdfDocument As Document = New Document(pdfFile)
        ' Initialize SvgSaveOptions
        Dim saveOptions As SvgSaveOptions = New SvgSaveOptions()
        ' Save SVG file
        pdfDocument.Save(svgFile, saveOptions)
    End Using

See Also