L_LoadSvg

#include "l_bitmap.h"

L_LTFIL_API L_INT EXT_FUNCTION L_LoadSvg(pszFile, pOptions, pLoadOptions)

L_TCHAR* pszFile;

name of the file to load

pLOADSVGOPTIONS pOptions;

pointer to a structure

pLOADFILEOPTION pLoadOptions;

pointer to optional extended load options

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

Parameter

Description

pszFile Character string containing the name of the file to load.
pOptions Pointer to a structure that contains the options used for loading SVG files. This can be NULL to use the default options.
pLoadOptions Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

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, you may need to get or set file information, such as the page number of a multi-page file or the resolution of a PCD file. Refer to Getting and Setting File Information.

Note: More options are available in the LOADFILEOPTION structure.

Use this function to load a page from any supported image, document or vector file as SVG (Scalable Vector Graphics). The following conditions must be met 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).

To find out if an input file can be loaded as SVG, use L_CanLoadSvg.

In addition to LTFIL, the following additional DLLs may be required to support loading 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.

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

You must check the resulting SVG document flatness and perform the necessary operation before continuing.

For more information, refer to Working With SVG.

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.

Platforms

Win32, x64.

See Also
Functions: L_CanLoadSvg, L_SvgLoadDocument, L_LoadBitmap, L_SetRasterizeDocOptions
Topics: Raster Image Functions: Loading Files
Raster Image Functions: Redirecting Input and Output
Loading and Saving Images
Working With SVG
SVG Size, Bounds and Flat
SVG Rendering

Example

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

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT LoadSvgExample(L_VOID) 
{ 
   L_INT nRet = 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; 
   nRet = L_CanLoadSvg(filename, &canLoad, NULL); 
   if(canLoad) 
   { 
      RASTERIZEDOCOPTIONS docOptions; 
      L_GetRasterizeDocOptions(&docOptions, sizeof(RASTERIZEDOCOPTIONS)); 
      docOptions.uXResolution = 300; 
      docOptions.uYResolution = 300; 
      L_SetRasterizeDocOptions(&docOptions); 
      nRet = L_LoadSvg(filename, &options, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      L_SvgSaveOptions saveOptions; 
      memset(&saveOptions, 0, sizeof(L_SvgSaveOptions)); 
      saveOptions.StructSize = sizeof(L_SvgSaveOptions); 
      saveOptions.Encoding = L_SvgEncoding_UTF16; 
      saveOptions.Formatted = TRUE; 
      nRet = L_SvgSaveDocument(MAKE_IMAGE_PATH(TEXT("Leadtools.pdf.svg")), options.SvgHandle, &saveOptions); 
      L_SvgFreeNode(options.SvgHandle); 
   } 
   return nRet; 
} 

Help Version 19.0.2017.10.18
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS SVG C API Help