<!--
{
  "availability" : [
    "macOS: 10.9.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/saveToPDF(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)saveDocumentToPDF:"
  },
  "title" : "saveToPDF(_:)"
}
-->

# saveToPDF(_:)

Exports a PDF representation of the document’s current contents.

```
@IBAction func saveToPDF(_ sender: Any?)
```

## Parameters

`sender`

The control sending the message.

## Discussion

This action method handles the File menu’s “Export As PDF…” item in a document-based application.

The default implementation of this method calls the [`print(withSettings:showPrintPanel:delegate:didPrint:contextInfo:)`](/documentation/AppKit/NSDocument/print(withSettings:showPrintPanel:delegate:didPrint:contextInfo:)) method, passing a print settings object that contains only the disposition ([`save`](/documentation/AppKit/NSPrintInfo/JobDisposition-swift.struct/save)), with user interaction disabled and `NULL` or `nil` for all other parameters.

If your document subclass supports creating PDF representations, you can override this method, if needed.

> Important:
> This method does not copy the document’s ``doc://com.apple.appkit/documentation/AppKit/NSDocument/printInfo`` to the operation object when creating a PDF printing operation. Your app should maintain a separate ``doc://com.apple.appkit/documentation/AppKit/NSPrintInfo`` instance specifically for creating PDFs and pass it to the print operation’s ``doc://com.apple.appkit/documentation/AppKit/NSPrintOperation/printInfo`` method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)