API referenceCore SDK

pdfCalcWidthHeight

Compute the missing dimension when scaling an object

C
double __stdcall pdfCalcWidthHeight(PPDF IPDF, double OrgWidth, double OrgHeight, double ScaledWidth, double ScaledHeight);
Delphi
function pdfCalcWidthHeight(const IPDF: PPDF; OrgWidth, OrgHeight, ScaledWidth, ScaledHeight: Double): Double; stdcall;

Purpose. Compute the missing dimension when scaling an object proportionally: given one target dimension, return the other, preserving OrgWidth/OrgHeight's aspect ratio. A pure math utility — does not consult IPDF at all despite accepting the parameter.

Description. If ScaledWidth > 0, returns the matching height (ScaledWidth * OrgHeight / OrgWidth); else if ScaledHeight > 0, returns the matching width (ScaledHeight * OrgWidth / OrgHeight); else 0.0. A source comment notes this corrects an earlier bug where the ScaledHeight branch merely echoed ScaledHeight back instead of computing the matching width.

Parameters.

ParameterDescription
IPDFAccepted but not consulted — pure math, works with any handle including an invalid one.
OrgWidth, OrgHeightOriginal dimensions; both must be > 0 or the result is 0.0.
ScaledWidthIf > 0, the known target width — the function returns the matching height.
ScaledHeightUsed only if ScaledWidth <= 0; if > 0, the function returns the matching width.

Return value. The computed matching dimension; 0.0 if OrgWidth/ OrgHeight aren't both positive, or neither ScaledWidth nor ScaledHeight is positive.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern double pdfCalcWidthHeight(IntPtr IPDF, double OrgWidth, double OrgHeight, double ScaledWidth, double ScaledHeight);
Area
Core SDK
Category

Core

Exported names

pdfCalcWidthHeight

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.