double __stdcall pdfCalcWidthHeight(PPDF IPDF, double OrgWidth, double OrgHeight, double ScaledWidth, double ScaledHeight);
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.
| Parameter | Description |
|---|---|
IPDF | Accepted but not consulted — pure math, works with any handle including an invalid one. |
OrgWidth, OrgHeight | Original dimensions; both must be > 0 or the result is 0.0. |
ScaledWidth | If > 0, the known target width — the function returns the matching height. |
ScaledHeight | Used 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)
public static extern double pdfCalcWidthHeight(IntPtr IPDF, double OrgWidth, double OrgHeight, double ScaledWidth, double ScaledHeight);
Core
pdfCalcWidthHeight
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.