BOOL32 __stdcall rptPreviewA(TRPTJOB Job, const char* Title);
BOOL32 __stdcall rptPrintA(TRPTJOB Job, const char* PrinterName, const char* OutputFile);
function rptPreviewA(const Job: TRPTJOB; const Title: PAnsiChar): LongBool; stdcall;
function rptPrintA(const Job: TRPTJOB; const PrinterName, OutputFile: PAnsiChar): LongBool; stdcall;
Purpose. rptPreview shows the engine's own built-in modal preview window (a real GUI component, per the conceptual chapter's own description). rptPrint sends the rendered report to a real Windows printer, with an optional file-routing mode for headless print-to-file workflows (e.g. via the "Microsoft Print to PDF" virtual printer, per an inline source comment).
Description. Both call J.Preview(Title)/J.Print(PrinterName, OutputFile) respectively, with the same RuntimeVerify + structured exception-to-error-sink handling as render/export. rptPreviewW(Job, Title=nil) shows the preview with an empty title rather than failing. rptPrint requires a non-empty PrinterName — an empty/nil printer name is a hard failure, unlike OutputFile, which is genuinely optional (empty = normal print to the named printer; non-empty = route the print job to that file instead, for print-driver-based headless file generation).
Parameters.
| Parameter | Description |
|---|---|
Job | Target job handle (rendered or not — Preview/Print presumably trigger an implicit render if needed; not independently confirmed in this chapter). |
Title | *(Preview only)* Window title; nil/empty is a valid, non-failing default. |
PrinterName | *(Print only)* Required — empty/nil fails immediately. |
OutputFile | *(Print only)* Optional; routes the print job to a file instead of a literal print spool when non-empty. |
Return value. True on success.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Reporting
rptPrintW
rptPrint
rptPrintA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.