fltk.print
FLTK Printing Support
This module provides printing functionality:
- Printer: Interface for outputting to physical printers
- PostScriptDevice: Interface for generating PostScript files
License
BSD-3-ClauseCopyright
Copyright © 2025 DDN (D Developer Network) Members
Types 4
Printer class for outputting to physical printers.
The Printer class provides an interface for printing widgets and windows to physical printers. It supports multi-page documents, transformations (scale, rotate, translate), and printing of individual widgets or entire windows.
Typical usage:
- Create a Printer instance
- Call startJob() to begin printing
- For each page: a. Call startPage() b. Use printWidget() or printWindow() to print content c. Call endPage()
- Call endJob() to finish
Example:
auto printer = new Printer();
if (printer.startJob(1)) {
if (printer.startPage()) {
printer.printWidget(myWidget, 0, 0);
printer.endPage();
}
printer.endJob();
}PrinterPtr _handlebool startJob(int pagecount = 0)Starts a print job.bool startJob(int pagecount, out int fromPage, out int toPage)Starts a print job with page range output.void endJob()Ends the current print job.bool startPage()Starts a new page.bool endPage()Ends the current page.bool printableRect(out int width, out int height)Gets the printable rectangle dimensions.void margins(out int left, out int top, out int right, out int bottom)Gets the page margins.void origin(out int x, out int y)Gets the current drawing origin.void setOrigin(int x, int y)Sets the drawing origin.void scale(float scaleX, float scaleY = 0)Scales the drawing.void rotate(float angle)Rotates the drawing.void translate(int x, int y)Translates the drawing origin.void untranslate()Removes the last translation.void printWidget(Widget widget, int deltaX = 0, int deltaY = 0)Prints a widget.void printWindow(Window window, int deltaX = 0, int deltaY = 0)Prints a window and all its contents.void setCurrent()Sets this printer as the current drawing surface.bool isSupported()Checks if printing is supported on this platform.this()Creates a new printer object.Page format constants for PostScript output.
These values correspond to standard paper sizes.
Page layout constants for PostScript output.
PostScript file device for generating PostScript output files.
The PostScriptDevice class provides an interface for generating PostScript files from FLTK widgets and windows. It supports multi-page documents, transformations, and various paper sizes.
Typical usage:
- Create a PostScriptDevice instance
- Call startJob() with a filename to begin output
- For each page: a. Call startPage() b. Use printWidget() or printWindow() to output content c. Call endPage()
- Call endJob() to finish and close the file
Example:
auto ps = new PostScriptDevice();
if (ps.startJob("output.ps", 1)) {
if (ps.startPage()) {
ps.printWidget(myWidget, 0, 0);
ps.endPage();
}
ps.endJob();
}PostScriptFileDevicePtr _handlebool startJob(string filename, int pagecount = 0,
PageFormat format = PageFormat.A4, PageLayout layout = PageLayout.PORTRAIT)Starts a PostScript output job to a file.void endJob()Ends the current PostScript job and closes the file.bool startPage()Starts a new page.bool endPage()Ends the current page.bool printableRect(out int width, out int height)Gets the printable rectangle dimensions.void margins(out int left, out int top, out int right, out int bottom)Gets the page margins.void origin(out int x, out int y)Gets the current drawing origin.void origin(int x, int y)Sets the drawing origin.void scale(float scaleX, float scaleY = 0)Scales the drawing.void rotate(float angle)Rotates the drawing.void translate(int x, int y)Translates the drawing origin.void untranslate()Removes the last translation.void printWidget(Widget widget, int deltaX = 0, int deltaY = 0)Prints a widget to the PostScript output.void printWindow(Window window, int deltaX = 0, int deltaY = 0)Prints a window and all its contents to the PostScript output.void setCurrent()Sets this device as the current drawing surface.this()Creates a new PostScript file device.