pdfSetPrinterDevModeFromString
Get/set a hex-encoded serialization of a printer's
const char* __stdcall pdfGetPrinterDevModeToStringA(PPDF IPDF, const char* PrinterName);
int32_t __stdcall pdfSetPrinterDevModeFromString(PPDF IPDF, const char* Source);
function pdfGetPrinterDevModeToStringA(const IPDF: PPDF; PrinterName: PAnsiChar): PAnsiChar; stdcall;
function pdfSetPrinterDevModeFromString(const IPDF: PPDF; Source: PAnsiChar): Integer; stdcall;
Purpose. Get/set a hex-encoded serialization of a printer's DEVMODE structure — intended, per an inline comment, to let a caller persist/restore print settings ("what a print path would consume").
Description. Real, self-consistent get/set round-trip, but verified NOT consumed by this SDK's own print execution. pdfSetPrinterDevModeFromString stores Source into a module-global FCurDevMode; pdfGetPrinterDevModeToString returns FCurDevMode if it's been set (bypassing any real printer-driver query entirely once set), else falls back to querying the named printer's actual current DEVMODE and hex-encoding it fresh. Inside the engine unit, FCurDevMode is read/written only by this get/set pair itself — it is never consulted by PrintPageToDC (the real function pdfPrintPage/ pdfPrintPDFFile, Print Execution, Settings, and Preview Bitmaps, actually call to render onto a DC) — despite the inline comment's claim that this "is what a print path would consume," no such consumption was found anywhere in this codebase. Practical implication: calling pdfSetPrinterDevModeFromString has no observable effect on subsequent pdfPrintPage/pdfPrintPDFFile calls — a caller wanting the DEVMODE to actually affect printing must apply it to the HDC themselves (e.g. via ResetDC/CreateDC) before passing that DC to this SDK's print functions.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
PrinterName | *(Get only)* Used only as a fallback query target if no DEVMODE has been set via the setter yet. |
Source | *(Set only)* Hex-encoded DEVMODE bytes to store. |
Return value. pdfGetPrinterDevModeToString: the hex-encoded DEVMODE string. pdfSetPrinterDevModeFromString: 1 if Source decoded successfully; 0 otherwise.
C# (P/Invoke)
public static extern int pdfSetPrinterDevModeFromString(IntPtr IPDF, IntPtr Source);
Setters
pdfSetPrinterDevModeFromString
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.