API referenceCore SDK

pdfFreePDF

Create a new document handle (pdfNewPDF); destroy one

C
PPDF __stdcall pdfNewPDF(void);
BOOL32 __stdcall pdfDeletePDF(PPDF IPDF);
BOOL32 __stdcall pdfFreePDF(PPDF IPDF);
Delphi
function pdfNewPDF: PPDF; stdcall;
function pdfDeletePDF(const IPDF: PPDF): LongBool; stdcall;
function pdfFreePDF(const IPDF: PPDF): LongBool; stdcall;

Purpose. Create a new document handle (pdfNewPDF); destroy one (pdfDeletePDF/pdfFreePDF — two names for the identical operation).

Description. pdfNewPDF allocates a fresh TLumasPdfDoc and registers it in the process-wide GHandleTable, returning the opaque PPDF handle every other API in this SDK takes as its first parameter — this is the one true "create a document" entry point (contrast with pdfCreateNewPDF/pdfOpenOutputFile, which instead open the *output file* for an already-created handle). pdfDeletePDF and pdfFreePDF are verified to be the literal identical implementation — both resolve the handle in GHandleTable, unregister it, and free the underlying TLumasPdfDoc object; there is no behavioral difference between the two names, and no distinction between "delete" (implying discard unsaved changes) and "free" (implying only memory cleanup) — either call unconditionally destroys the document object regardless of whether pdfCloseFile was ever called to write it out first.

Parameters.

ParameterDescription
IPDF*(Delete/Free only)* The handle to destroy.

Return value. pdfNewPDF: the new document handle (never fails). pdfDeletePDF/pdfFreePDF: True if IPDF resolved and was destroyed; False if it was already invalid/freed.

Remarks. Calling pdfDeletePDF/pdfFreePDF without first calling pdfCloseFile discards any pending unwritten output — this pair performs no implicit flush.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Core SDK
Category

Core

Exported names

pdfFreePDF

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.