LFile::ReadFileAttachments

Summary

Reads the properties of the attachments embedded in the specified file.

Syntax

#include "ltwrappr.h"

L_INT LFile::ReadFileAttachments(pszFile, ppAttachments, pLoadOptions, pInfo)

Parameters

L_TCHAR *pszFile

Character string containing the name of the owner file that may contain embedded attachments.

L_FILEATTACHMENTS **ppAttachments

Pointer to a variable that will be populated with the properties of any attachments found.

LOADFILEOPTION *pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options. Refer to LFile::LoadFile for more information.

FILEINFO *pInfo

Pointer to a FILEINFO structure. This structure may contain file information used in loading an image, or it may be updated with information about the file being loaded.

This value can be NULL.

Refer to LFile::LoadFile for more information.

Returns

Value Meaning
SUCCESS The function was successful.
ERROR_NO_ATTACHMENTS The file formats supports attachments but the file does not have attachments.
ERROR_FEATURE_NOT_SUPPORTED The file format does not support attachments.
ERROR_PDF_INVALID_PASSWORD The owner file is encrypted. Set the correct owner file password using LFileSettings::SetPDFOptions and try again.
< 1 An error occurred. Refer to Return Codes.

Comments

Applications can read the properties of the attachments included in a file by performing the following steps:

  1. Declare a pointer of type L_FILEATTACHMENTS and set its value to NULL.
  2. Call LFile::ReadFileAttachments on the owner file containing attachments, passing the address of the L_FILEATTACHMENTS pointer.
  3. Process the attachments. An example of processing the attachments would be calling LFile::ExtractAttachment to extract the attachment's file data.
  4. When the data is no longer needed, call LFile::FreeAttachments on the pointer to free the memory used by *ppAttachments (the L_FILEATTACHMENTS pointer).

[LFile:ReadFileAttachments returns the following values:

The number of attachment items returned by this method is the same as the FILEINFO.nAttachmentCount value of the object returned by LFile::GetInfo.

Each L_FILEATTACHMENT contains properties of the attachment such as its pszFileName, uFileLength, and other information provided by the owner document.

Use LFile::ExtractAttachment to extract the binary content of the attachment file into an output disk file or stream for further processing (for example, by calling LFile::GetInfo or LFile::Load).

LEADTOOLS supports reading the attachments embedded in the following file format:

PDF

PDF files support embedded attachments of any number and file format (such as PDF, TIFF, XML, etc). PDF files can also be created as a portfolio which contains multiple files assembled into an integrated unit. In these types of documents, the file contains a single generic help page with text such as "For the best experience, open this PDF portfolio in a compatible viewer", as well as any number of attachments and a schema to control how to view the document. The value of FILEINFO.uFlags will contain FILEINFO_PORTFOLIO if the file is a PDF portfolio, and it is up to the application to specify any further handling of the file.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example will do the following :

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

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.