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


#include "l_bitmap.h"

L_LTFIL_API L_INT L_ReadFileAttachments(pszFile, ppAttachments, pLoadOptions, pInfo)


L_TCHAR *pszFile

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


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


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


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 L_LoadFile for more information.


Value Meaning
SUCCESS The function was successful.
ERROR_NO_ATTACHMENTS The file is a format that supports attachments, such as PDF, but no attachments were found.
ERROR_FEATURE_NOT_SUPPORTED The file is a format that does not support attachments (such as PNG or BMP), or LEADTOOLS does not support reading attachments of this type of format.
ERROR_PDF_INVALID_PASSWORD The owner file is encrypted. Pass the correct password using L_SetPDFOptions and try again.
< 1 An error occurred. Refer to Return Codes.


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 L_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 L_ExtractAttachment to extract the attachment's file data.
  4. When the data is no longer needed, call L_FreeAttachments on the pointer to free the memory used by L_FILEATTACHMENTS.

L_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 L_FileInfo.

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

Use L_ExtractAttachment to extract the binary content of the attachment file into an output disk file or stream for further processing (for example, by calling L_FileInfo or L_LoadBitmap).

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


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


Win32, x64, Linux.

See Also



This example will do the following:

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

LEADTOOLS Raster Imaging C API Help

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