API referenceImport & Output APIs

pdfOpenImportBuffer

Open a PDF held in a memory buffer as the import source.

Exported namespdfOpenImportBuffer
NotePassword parameters are not applied — see Remarks

Purpose — Open a PDF held in a memory buffer as the import source.

Description — Copies the buffer into an internal stream (the caller's buffer may be freed immediately after the call returns) and parses it exactly like a file source. Closes any previous import source first.

C
int32_t __stdcall pdfOpenImportBuffer(PPDF IPDF, void* Buffer, uint32_t BufSize, int32_t PwdType, const char* Password);
Delphi
function pdfOpenImportBuffer(const IPDF: PPDF; const Buffer: Pointer; BufSize: Cardinal;
  PwdType: Integer; const Password: PAnsiChar): Integer; stdcall; external 'LumasPdf.dll';

Return value — 0-based handle: 0 on success, -1 on error (NULL buffer, zero size, or not a valid PDF).

Remarks — In the current implementation the PwdType/Password arguments are not applied for buffer sources: an encrypted buffer opens only if it decrypts with the empty password. Write the encrypted bytes to a temporary file and use pdfOpenImportFile when a real password is needed. pdfReOpenImportFile does not work for buffer sources (no path is recorded).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfOpenImportBuffer(IntPtr IPDF, IntPtr Buffer, uint BufSize, int PwdType, [MarshalAs(UnmanagedType.LPStr)] string Password);
Area
Import & Output APIs
Category

Import

Exported names

pdfOpenImportBuffer

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.