fltk.print

FLTK Printing Support

This module provides printing functionality:

  • Printer: Interface for outputting to physical printers
  • PostScriptDevice: Interface for generating PostScript files

    Authors

    Dejan Lekić

    License

    BSD-3-Clause

Types 4

classPrinter

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:

  1. Create a Printer instance
  2. Call startJob() to begin printing
  3. For each page: a. Call startPage() b. Use printWidget() or printWindow() to print content c. Call endPage()
  4. 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();
}

Fields
PrinterPtr _handle
Methods
bool isValid() const @safe nothrow @nogcReturns whether the printer handle is valid.
PrinterPtr handle() @safe nothrow @nogcReturns the underlying printer handle.
bool 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.
Constructors
this()Creates a new printer object.
Destructors

Page format constants for PostScript output.

These values correspond to standard paper sizes.

A0 = 0
A1
A2
A3
A4
A5
A6
A7
A8
A9
B0
B1
B2
B3
B4
B5
B6
B7
B8
B9
B10
C5E
DLE
EXECUTIVE
FOLIO
LEDGER
LEGAL
LETTER
TABLOID
ENVELOPE
MEDIA = 0x1000

Page layout constants for PostScript output.

PORTRAIT = 0
LANDSCAPE = 0x100
REVERSED = 0x200
ORIENTATION = 0x300

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:

  1. Create a PostScriptDevice instance
  2. Call startJob() with a filename to begin output
  3. For each page: a. Call startPage() b. Use printWidget() or printWindow() to output content c. Call endPage()
  4. 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();
}

Methods
bool isValid() const @safe nothrow @nogcReturns whether the device handle is valid.
PostScriptFileDevicePtr handle() @safe nothrow @nogcReturns the underlying device handle.
bool 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.
Constructors
this()Creates a new PostScript file device.
Destructors