Some test text!

Loading...
Guides
Print a document

Print a PDF to a printer in Go

To print a PDF to a default printer.

doc := NewPDFDoc(filename)

// Set our PrinterMode options
printerMode := NewPrinterMode()
printerMode.SetCollation(true)
printerMode.SetCopyCount(1)
printerMode.SetDPI(100); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterModeE_Duplex_Auto)

// Print the PDF document to the default printer, using "tiger.pdf" as the document
// name, send the file to the printer not to an output file, print all pages, set the printerMode
// and a cancel flag to true
pageSet := NewPageSet(1, doc.GetPageCount())
boolValue := true
PrintStartPrintJob(doc, "", doc.GetFileName(), "", pageSet, printerMode, &boolValue)

Print a PDF file
Full sample code which illustrates how to print a PDF document using the currently selected default printer.

Get the answers you need: Support