#include "l_bitmap.h"

L_LTFIL_API L_INT EXT_FUNCTION L_LoadSvg(pszFile, pOptions, pLoadOptions)

Loads a page from an image, document or vector file as an SVG file.


L_TCHAR* pszFile

Character string containing the name of the file to load.


Pointer to a structure that contains the options used for loading SVG files. This can be NULL to use the default options.


Pointer to optional extended load options. Pass NULL to use the default load options.


Value Meaning
SUCCESS The function was successful.
<1 An error occurred. Refer to Return Codes.


Support for loading as SVG is only available in Document and Medical Imaging toolkits.

Before calling this function, it may be necessary to get or set file information, such as the page number of a multipage file or the resolution of a PCD file. Refer to Getting and Setting File Information.

Use this function to load a page from any supported image, document, or vector format as SVG (Scalable Vector Graphics). All of the following conditions must be met in order for L_LoadSvg to load a page from a file as SVG:

Condition Description
The file format is SVG SVG can be loaded as SVG (SVG files can also be loaded using L_SvgLoadDocument).
The file format is document The file is in one of the document file formats supported by LEADTOOLS such as DOC/DOCX, PPT/PPTX, XLS/XLSX, RTF, TXT, AFP, ICA, etc.
These formats will set the FILEINFO.bIsDocFile member to TRUE when calling L_FileInfo.
The file format is vector The file is in one of of the vector file formats supported by LEADTOOLS such as DXF, DWG, etc.
These formats will set the FILEINFO.bIsVectorFile member to TRUE when calling L_FileInfo.
The file format is PDF And the PDF file contains more than pure raster data (for example, not scanned PDF file).
A completely raster PDF file will return an error.

To find out whether an input file can be loaded as SVG, call L_CanLoadSvg or L_CanLoadSvg2.

The SVG loaded by this function will be returned in the LOADSVGOPTIONS structure.

Be sure to check the resulting SVG document for flatness and perform any necessary operations before continuing.

For more information, refer to Working With SVG.

Note: More options are available in the LOADFILEOPTION structure.

Required DLLs and Libraries

LTFIL File format DLLs For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. In addition to LTFIL, the following additional DLLs may be required to support loading a file as SVG:

DLL Description
LTSVG SVG support. Always required.
LTVKRN Required if the input document is a vector file.
LTPDF Required if the input document is a PDF file.


Win32, x64.

See Also




This example loads a PDF file as SVG and then saves the document out as SVG.

L_INT LoadSvgExample(L_VOID) 
   memset(&options, 0, sizeof(LOADSVGOPTIONS)); 
   options.uStructSize = sizeof(LOADSVGOPTIONS); 
   options.uFlags = L_LOADSVGOPTIONS_NONE; 
   options.SvgHandle = NULL; 
   /* Load the document as SVG */ 
   L_TCHAR filename[L_MAXPATH] = MAKE_IMAGE_PATH(TEXT("Leadtools.pdf")); 
   L_BOOL canLoad = FALSE; 
   ret = L_CanLoadSvg(filename, &canLoad, NULL); 
      L_GetRasterizeDocOptions(&docOptions, sizeof(RASTERIZEDOCOPTIONS)); 
      docOptions.uXResolution = 300; 
      docOptions.uYResolution = 300; 
      ret = L_LoadSvg(filename, &options, NULL); 
      if(ret != SUCCESS) 
         return ret; 
      L_SvgSaveOptions saveOptions; 
      memset(&saveOptions, 0, sizeof(L_SvgSaveOptions)); 
      saveOptions.StructSize = sizeof(L_SvgSaveOptions); 
      saveOptions.Encoding = L_SvgEncoding_UTF16; 
      saveOptions.Formatted = TRUE; 
      ret = L_SvgSaveDocument(MAKE_IMAGE_PATH(TEXT("Leadtools.pdf.svg")), options.SvgHandle, &saveOptions); 
   return ret; 

Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.