L_LoadDoc (original) (raw)
Summary
Loads and converts one or more pages from a document file to a PDF file.
Syntax
#include "l_bitmap.h"
L_LTFIL_API L_INT EXT_FUNCTION L_LoadDoc(pszFile, pOptions, pLoadOptions, pFileInfo)
Parameters
L_TCHAR* pszFile
Character string containing the name of the file to load.
pDOCUMENTCREATEFILEOPTIONS pOptions
Pointer to a structure that contains the options used for creating the output file. Cannot be NULL.
pLOADFILEOPTION pLoadOptions
Pointer to optional extended load options. Pass NULL to use the default load options.
pFILEINFO pFileInfo
Pointer to optional file information structure. Pass NULL if you do not know or do not need to know the format of the source file.
Returns
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
ERROR_NULL_PTR | pszFile or pOptions are NULL. |
ERROR_LTDOCWRT_MISSING | LTDOCWRT DLL is missing. |
< 1 | An error occurred. Refer to Return Codes. |
Comments
Support for loading files as DOC/PDF is only available in the Document and Medical Imaging toolkits.
Use this function to load one or more pages from a source file as PDF. Currently, this function only converts the source file to PDF. In the future, this function will be able to create other document file formats as well.
Use L_CanLoadDoc to determine whether a source file can be loaded and converted to PDF format. See L_CanLoadDoc to find out which source files can be converted using L_LoadDoc.
The DOCUMENTCREATEFILEOPTIONS specifies the following options for creating the output file:
- The output file name in DOCUMENTCREATEFILEOPTIONS.pszFileName
- The output file format in DOCUMENTCREATEFILEOPTIONS.Format (currently only DOCUMENTFORMAT_PDF)
- Various options specific to the output file format in DOCUMENTCREATEFILEOPTIONS.pOptions (currently, only pointers to a DOCWRTPDFOPTIONS structure).
- The resolution at which the source file should be loaded in DOCUMENTCREATEFILEOPTIONS.DpiX and DpiY
- The starting and ending pages that should be converted in DOCUMENTCREATEFILEOPTIONS.FirstPageNumber and LastPageNumber
See DOCUMENTCREATEFILEOPTIONS for more details about the DOCUMENTCREATEFILEOPTIONS structure.
If you know the format of the source file, you can speed up loading by passing a pointer to a FILEINFO structure describing the source file. The structure can contain either all information or only partial information. See Using FILEINFO to Speed up the Load for more details.
If you do not know the source file format but would like to obtain it, pass a pointer to a FILEINFO structure in which uStructSize = sizeof(FILEINFO) and Flags = 0 or FILEINFO_FORMATVALID or FILEINFO_NAMEVALID. The function will then fill the rest of FILEINFO structure members.
Note: More options are available in the LOADFILEOPTION structure.
Additional DLLs/assemblies are required to support loading a PDF file. L_CanLoadDoc lists them.
Platforms
Win32, x64.
See Also
Functions
Topics
- Raster Image Functions: Loading Files
- Raster Image Functions: Redirecting Input and Output
- Loading and Saving Images
- Using FILEINFO to speed up the load
Example
This example loads a DOCX file and converts it to DOC/PDF. In addition, the output PDF file is created as image over text.
L_INT LoadDocExample(L_VOID)
{
L_INT nRet = ERROR_FILE_FORMAT;
FILEINFO FileInfo = {sizeof(FILEINFO)};
/* Load the document as PDF */
L_TCHAR filename[L_MAXPATH] = MAKE_IMAGE_PATH(TEXT("SourceFile.docx"));
L_BOOL canLoad = FALSE;
nRet = L_CanLoadDoc(filename, &canLoad, NULL, &FileInfo);
if(nRet == SUCCESS && canLoad)
{
DOCWRTPDFOPTIONS docWrtOptions = {0};
docWrtOptions.Options.uStructSize = sizeof(DOCWRTPDFOPTIONS);
docWrtOptions.bImageOverText = L_TRUE;
DOCUMENTCREATEFILEOPTIONS documentCreateFileOptions = {sizeof(DOCUMENTCREATEFILEOPTIONS)};
documentCreateFileOptions.pszFileName = MAKE_IMAGE_PATH(TEXT("out.pdf"));
documentCreateFileOptions.Format = DOCUMENTFORMAT_PDF;
documentCreateFileOptions.pOptions = &docWrtOptions; /* Set this to NULL to create regular PDF files */
documentCreateFileOptions.DpiX = 300; /* Load the source file as 300 DPI */
documentCreateFileOptions.DpiY = 300;
documentCreateFileOptions.FirstPageNumber = 0; /* load all the pages */
documentCreateFileOptions.LastPageNumber = 0;
nRet = L_LoadDoc(filename, &documentCreateFileOptions, NULL, &FileInfo);
if(nRet != SUCCESS)
return nRet;
}
return nRet;
}