exported(as:)
Using the type’s Transferable conformance implementation, exports a value as binary data, optionally with a specified configuration for that type of data.
Declaration
nonisolated final func exported(as representation: WebPage.ExportedContentConfiguration) async throws -> DataParameters
- representation:
A configuration for a representation for a specific type of data with optional customizable properties.
Return Value
The data with the specified representation type.
Discussion
For example, you can export a 100 pt by 100 pt region of a webpage as a PDF, and allow it to have a transparent background:
let page = WebPage()
// Load web content and wait for navigation to complete.
let square = CGRect(x: 0, y: 0, width: 100, height: 100)
let pdf = try await page.exported(as: .pdf(region: .rect(square), allowTransparentBackground: true))If no configuration is needed, use the Transferable conformance of WebPage directly:
let page = WebPage()
// Load web content and wait for navigation to complete.
let pdf = try await page.exported(as: .pdf)