1. Home
  2. Foxit Quick PDF Library
  3. Custom printing options

Custom printing options

Foxit Quick PDF Library can print PDF files to installed physical printers (e.g. Lexmark S300 Series) or virtual printers (e.g. Microsoft XPS Document Writer). If you do not need granular control over the printer settings then you can use the PrintDocument and PrintOptions functions. However, if you need to control exactly what is happening when the document is printed then you can use the NewCustomPrinter and SetupCustomPrinter functions.

Here are examples written in C# and Delphi source code which demonstrate how to use the custom printer functions to customize the printing options:

C# Sample Code

/* Create a custom printer and specify your own settings  */
 
// Load a sample file from the input folder
 
DPL.LoadFromFile("test.pdf", ""); 
 
// Create the custom printer
 
string CustomPrinter = DPL.NewCustomPrinter("Microsoft XPS Document Writer");
 
// Setup the settings for the customer printer
 
// Medium quality
 
DPL.SetupCustomPrinter(CustomPrinter, 5, 2); 
 
// Monochrome
 
DPL.SetupCustomPrinter(CustomPrinter, 6, 1); 
 
// Horizontal Duplex
 
DPL.SetupCustomPrinter(CustomPrinter, 7, 3);
 
// Configure print options
 
int iPrintOptions = DPL.PrintOptions(0, 0, "Printing Sample");
 
// Print the current document to the default printing 
// using the options as configured above
 
DPL.PrintDocument(CustomPrinter, 1, 1, iPrintOptions);

Delphi Sample Code

procedure TForm6.PrintDocumentClick(Sender: TObject);
var
iPrintOptions: Integer;
CustomPrinter: AnsiString;
begin
  DPL := TDebenuPDFLibrary1115.Create;
  try
    UnlockResult := DPL.UnlockKey('ji9zq4d57r78at8nk5d76gt9y'); // Add trial license key here
    if UnlockResult = 1 then
      begin
        // Load a sample file from the input folder
 
        DPL.LoadFromFile('test.pdf', '');
 
        // Create the custom printer
 
        CustomPrinter := DPL.NewCustomPrinter(DPL.GetDefaultPrinterName());
 
        // Setup the settings for the customer printer
 
        // Medium quality
 
        DPL.SetupCustomPrinter(CustomPrinter, 5, 2);
 
        // Monochrome
 
        DPL.SetupCustomPrinter(CustomPrinter, 6, 1);
 
        // Horizontal Duplex
 
        DPL.SetupCustomPrinter(CustomPrinter, 7, 3);
 
        // Configure print options
 
        iPrintOptions := DPL.PrintOptions(0, 0, 'Printing Sample');
 
        // Print the current document to the default printing
        // using the options as configured above
 
        DPL.PrintDocument(CustomPrinter, 1, 1, iPrintOptions);
      end;
    finally
    DPL.Free;
  end;
end;
Updated on April 9, 2017

Was this article helpful?

Related Articles

Ready to try Foxit PDF SDK?
Click the link below to download your trial
Free Trial