L_LoadSvg

#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.

Parameters

L_TCHAR* pszFile

Character string containing the name of the file to load.

pLOADSVGOPTIONS pOptions

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

pLOADFILEOPTION pLoadOptions

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

Returns

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

Comments

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.
A document file can also be loaded as SVG by calling L_SvgLoadDocument.
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.
LVKRN Required if the input document is a vector file.
LTPDF Required if the input document is a PDF file.

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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

L_INT LoadSvgExample(L_VOID) 
{ 
   L_INT ret = ERROR_FILE_FORMAT; 
 
   LOADSVGOPTIONS options; 
   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); 
   if(canLoad) 
   { 
      RASTERIZEDOCOPTIONS docOptions; 
      L_GetRasterizeDocOptions(&docOptions, sizeof(RASTERIZEDOCOPTIONS)); 
      docOptions.uXResolution = 300; 
      docOptions.uYResolution = 300; 
      L_SetRasterizeDocOptions(&docOptions); 
      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); 
 
      L_FreeSvg(options.SvgHandle); 
   } 
 
   return ret; 
} 

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

LEADTOOLS SVG C API Help