---
title: "write(toFile:withOptions:)"
framework: pdfkit
role: symbol
role_heading: Instance Method
path: "pdfkit/pdfdocument/write(tofile:withoptions:)"
---

# write(toFile:withOptions:)

Writes the document to a file at the specified path with the specified options.

## Declaration

```swift
func write(toFile path: String, withOptions options: [PDFDocumentWriteOption : Any]? = nil) -> Bool
```

## Discussion

Discussion The most commonly-used options are kCGPDFContextOwnerPassword, kCGPDFContextUserPassword, kCGPDFContextAllowsCopying and kCGPDFContextAllowsPrinting. For more details about these options, see Auxiliary Dictionary Keys.

## See Also

### Related Documentation

- [dataRepresentation()](pdfkit/pdfdocument/datarepresentation().md)

### Writing Out the PDF Data

- [write(toFile:)](pdfkit/pdfdocument/write(tofile:).md)
- [write(to:)](pdfkit/pdfdocument/write(to:).md)
- [write(to:withOptions:)](pdfkit/pdfdocument/write(to:withoptions:).md)
- [Data Representations](pdfkit/data-representations.md)
