L_LoadSvg2

Summary

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

Syntax

#include "l_bitmap.h"

L_LTFIL_API L_INT L_LoadSvg2(pszFile, pOptions, pLoadOptions, pFileInfo)

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.

pFILEINFO pFileInfo

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 file as SVG (Scalable Vector Graphics).

This is an optimized version of L_LoadSvg, and provides the same functionality and support, but uses less memory.

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

After loading the file, be sure to check the resulting SVG document for flatness and perform any necessary operations before continuing.

Note: More options are available in the LOADFILEOPTION structure.

For more information, refer to Working With SVG.

Required DLLs and Libraries

LTSVG
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:

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

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

L_INT LoadSvg2Example(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")); 
 
   FILEINFO fileInfo; 
   L_BOOL canLoad = FALSE; 
   memset(&fileInfo, 0, sizeof(FILEINFO)); 
   fileInfo.uStructSize = sizeof(FILEINFO); 
 
   ret = L_CanLoadSvg2(filename, &canLoad, NULL, &fileInfo); 
   if(canLoad) 
   { 
      // Load the first page and save it to the disk 
      LOADFILEOPTION loadFileOption; 
      L_GetDefaultLoadFileOption(&loadFileOption, sizeof(LOADFILEOPTION)); 
      loadFileOption.PageNumber = 1; 
 
      ret = L_LoadSvg2(filename, &options, &loadFileOption, &fileInfo); 
      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_SvgFreeNode(options.SvgHandle); 
   } 
 
   return ret; 
} 

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

LEADTOOLS SVG C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.