API referenceCore SDK

pdfSetPageWidth

Get/set the current page's width/height — and, for the

C
double __stdcall pdfGetPageWidth(PPDF IPDF);
double __stdcall pdfGetPageHeight(PPDF IPDF);
BOOL32 __stdcall pdfSetPageWidth(PPDF IPDF, double Value);
BOOL32 __stdcall pdfSetPageHeight(PPDF IPDF, double Value);
Delphi
function pdfGetPageWidth(const IPDF: PPDF): Double; stdcall;
function pdfGetPageHeight(const IPDF: PPDF): Double; stdcall;
function pdfSetPageWidth(const IPDF: PPDF; Value: Double): LongBool; stdcall;
function pdfSetPageHeight(const IPDF: PPDF; Value: Double): LongBool; stdcall;

Purpose. Get/set the current page's width/height — and, for the setters, also stage the size for pages not yet created.

Description. The getters read the currently-open page's actual Width/Height. The setters have a real dual effect, per an explicit source comment documenting a past bug fix: they update the FPendingWidth/FPendingHeight values used to size the next page created via pdfAppend, and — if a page is currently open — resize that open page immediately too (Value <= 0 is silently rejected in both cases, leaving the prior size unchanged). Earlier engine behavior only staged the pending size and silently ignored an in-progress resize; this was fixed so calling pdfSetPageWidth/Height mid-page now takes effect immediately, matching the classic API's documented behavior.

Parameters.

ParameterDescription
IPDFDocument handle.
ValueNew width/height; <= 0 is silently ignored (no change).

Return value. Getters: the value in points; 0.0 if IPDF invalid or no page open. Setters: True if IPDF is valid (regardless of whether Value passed the > 0 check).

C# (P/Invoke)

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

Setters

Exported names

pdfSetPageWidth

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.