> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/print/printer.md).

# Print a PDF to a printer on Server/Desktop

Learn how to print a PDF file to a default printer with sample code. Follow step-by-step instructions to easily print PDF documents. The Apryse Server SDK streamlines secure document processing with r

To print a PDF to a default printer, basics.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFDoc pdfdoc = new PDFDoc(filename);

// Setup PrinterMode options
PrinterMode printerMode = new PrinterMode();
printerMode.SetCollation(true);
printerMode.SetCopyCount(1);
printerMode.SetDPI(600); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode.DuplexMode.e_Duplex_Auto);

// Print the document on the default printer, name the print job the name of the
// file, print to the printer not a file, and use printer options:
Print.StartPrintJob(pdfdoc, "", pdfdoc.GetFileName(), "", null, printerMode, null);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFDoc doc(filename);

// Setup PrinterMode options
PrinterMode printerMode;
printerMode.SetCollation(true);
printerMode.SetCopyCount(1);
printerMode.SetDPI(600); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode::e_Duplex_Auto);

// Print the document on the default printer, name the print job the name of the
// file, print to the printer not a file, and use printer options:
Print::StartPrintJob(doc, UString(""), doc.GetFileName(), UString(""), NULL, &printerMode, NULL );
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
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)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);

// Setup PrinterMode options
PrinterMode printerMode = new PrinterMode();
printerMode.setCollation(true);
printerMode.setCopyCount(1);
printerMode.setDPI(600); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.setDuplexing(PrinterMode.e_Duplex_Auto);

// Print the document on the default printer, name the print job the name of the
// file, print to the printer not a file, and use printer options:
Print.startPrintJob(doc, "", doc.getFileName(), "", null, printerMode, null);
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
- (void)handlePrintJob:(id)sender
{
    PTPrint *print = [[PTPrint alloc] init];
    [print PrepareDocToPrint:self.pdfDoc Delegate:[[MyPrintDelegate alloc] initWithView:self.view] UserData:sender];
}

@interface MyPrintDelegate : NSObject <PTPrintDelegate>

- (instancetype)initWithView:(UIView *)view;

@property (nonatomic, strong) UIView *view;

@end

@implementation MyPrintDelegate

- (instancetype)initWithView:(UIView *)view
{
    self = [super init];
    if (self) {
        _view = view;
    }
    return self;
}

- (void)PreparedToPrint:(NSString *)docFilePath UserData:(id)userData
{
    PTPrint *myPrint = [[PTPrint alloc] init];
    [myPrint PrintDoc:docFilePath FromRect:CGRectZero InView:self.view WithJobName:docFilePath Animated:YES CompletionHandler:nil];
}

@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
func handlePrintJob(sender: Any?) {
    let print = PTPrint()
    print.prepareDoc(toPrint: self.pdfDoc, delegate: MyPrintDelegate(self.view), userData: sender)
}

class MyPrintDelegate: NSObject, PTPrintDelegate {
    
    let view: UIView
    
    init(_ view: UIView) {
        self.view = view
    }
    
    func prepared(toPrint docFilePath: String!, userData: Any!) {
        let myPrint = PTPrint()
        myPrint.printDoc(docFilePath, from: .zero, in: self.view, withJobName: docFilePath, animated: true, completionHandler: nil)
    }
    
}
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc = new PDFDoc($filename);

// Setup PrinterMode options
$printerMode = new PrinterMode();
$printerMode->SetCollation(true);
$printerMode->SetCopyCount(1);
$printerMode->SetDPI(600); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
$printerMode->SetDuplexing(PrinterMode::e_Duplex_Auto);

// Print the document on the default printer, name the print job the name of the
// file, print to the printer not a file, and use printer options:
PDFPrint::StartPrintJob($doc, "", $doc->GetFileName(), "", null, $printerMode, null);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
doc = PDFDoc(filename)

# Setup PrinterMode options
printerMode = PrinterMode()
printerMode.SetCollation(True)
printerMode.SetCopyCount(1)
printerMode.SetDPI(600); # regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode.e_Duplex_Auto)

# Print the document on the default printer, name the print job the name of the
# file, print to the printer not a file, and use printer options:
Print.StartPrintJob(doc, "", doc.GetFileName(), "", None, printerMode, None)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc = PDFDoc.new(filename)

# Setup PrinterMode options
printerMode = PrinterMode.new
printerMode.SetCollation(true)
printerMode.SetCopyCount(1)
printerMode.SetDPI(100)		# regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode::E_Duplex_Auto)

# Print the document on the default printer, name the print job the name of the
# file, print to the printer not a file, and use printer options:
Print.StartPrintJob(doc, "", doc.GetFileName(), "", nil, printerMode, nil)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim doc As PDFDoc = New PDFDoc(filename)

' Setup printing options:
Dim printerMode As PrinterMode = New PrinterMode
printerMode.SetCollation(True)
printerMode.SetCopyCount(1)
printerMode.SetDPI(600)     ' regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(printerMode.DuplexMode.e_Duplex_Auto)

' Print the document on the default printer, name the print job the name of the 
' file, print to the printer not a file, and use default printer options:
Print.StartPrintJob(doc, "", doc.GetFileName(), "", Nothing, printerMode, Nothing)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Print a PDF file - Full Sample](/core/get-started/samples/pdfprinttest.md) Full sample code which illustrates how to print a PDF document using the currently selected default printer. Samples available in Python, C# (.Net), C++, Go, Java, PHP, Ruby, VB. To use this code, you'll need to [download and get started with Server SDK](/core/get-started/get-started.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/print/printer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
