Send PDFs to system printers or generate print-ready output for PostScript and PCL workflows. No GUI needed.
use pdfluent::{Sdk, print::{PrintOptions, DuplexMode, PrintRange}};
fn main() -> pdfluent::Result<()> {
let sdk = Sdk::new()?;
let doc = sdk.open("invoice.pdf")?;
let opts = PrintOptions::builder()
.printer_name("HP_LaserJet_M404")
.copies(1)
.duplex(DuplexMode::LongEdge)
.page_range(PrintRange::All)
.collate(true)
.build();
let job = doc.print(opts)?;
println!("Print job ID: {}", job.id());
println!("Status: {:?}", job.wait_for_completion()?);
Ok(())
}Run cargo add pdfluent@1.0.0-beta.5 to get started.
On Linux and macOS, PDFluent submits jobs via CUPS using the IPP protocol. On Windows, it uses the Win32 print spooler API (StartDocPrinter / WritePrinter). No external tools or shell commands are invoked.
Generate a PostScript file from any PDF for use with PS-capable printers or RIP software. The conversion handles fonts, transparency flattening, and color space mapping. Output conforms to DSC Level 3.
Add crop marks, bleed marks, registration marks, and color bars to a PDF before printing. Marks are placed outside the trim box in a configurable margin. Useful for commercial print workflows where the PDF is sent to a print service provider.
Impose multiple pages onto a single printed sheet. Supports 2-up, 4-up, 6-up, and 9-up layouts with configurable margins and gutter spacing. N-up is applied before sending to the printer or writing the output PDF.
Set duplex mode to single-sided, long-edge flip, or short-edge flip per job. On printers that support it, the duplex instruction is passed directly to the printer driver. For printers without duplex support, PDFluent interleaves pages for manual duplex.
List available printers and their capabilities, query job status by ID, and cancel queued jobs. Enumerate paper sizes and tray options supported by each printer before submitting.