Reference · Object · lib.rs
PdfDoc Object
An open PDF: what the apps show and look into. One per file; closed when the last reference goes.
class PdfDoc {
static func open(bytes: Data, password: String?) throws -> PdfDoc
func pageCount() -> UInt32
func pageSizes() -> [PageSize]
func render(page: UInt32, width: UInt32, annotations: Bool) throws -> RenderedPage
func text(page: UInt32) throws -> String
func words(page: UInt32) throws -> [TextWord]
func find(pages: [UInt32], pattern: String, caseInsensitive: Bool) throws -> [TextHit]
func looksScanned() -> Bool
func blankPages() throws -> [UInt32]
func contentBounds(page: UInt32) throws -> DisplayRect?
func pagesWithoutText() throws -> [UInt32]
func hasForm() throws -> Bool
func formWidgets() throws -> [FormWidget]
func fillForm(edits: [FormEdit]) throws -> Data
func chapterStarts() throws -> [UInt32]
func exportImage(page: UInt32, dpi: Double, png: Bool, quality: UInt8) throws -> Data
}public class PdfDoc {
public static PdfDoc Open(byte[] bytes, string? password)
public uint PageCount()
public PageSize[] PageSizes()
public RenderedPage Render(uint page, uint width, bool annotations)
public string Text(uint page)
public TextWord[] Words(uint page)
public TextHit[] Find(uint[] pages, string pattern, bool caseInsensitive)
public bool LooksScanned()
public uint[] BlankPages()
public DisplayRect? ContentBounds(uint page)
public uint[] PagesWithoutText()
public bool HasForm()
public FormWidget[] FormWidgets()
public byte[] FillForm(FormEdit[] edits)
public uint[] ChapterStarts()
public byte[] ExportImage(uint page, double dpi, bool png, byte quality)
}impl PdfDoc {
pub fn open(bytes: Vec<u8>, password: Option<String>) -> Result<Arc<PdfDoc>, PagewerkError>
pub fn page_count(&self) -> u32
pub fn page_sizes(&self) -> Vec<PageSize>
pub fn render(&self, page: u32, width: u32, annotations: bool) -> Result<RenderedPage, PagewerkError>
pub fn text(&self, page: u32) -> Result<String, PagewerkError>
pub fn words(&self, page: u32) -> Result<Vec<TextWord>, PagewerkError>
pub fn find(&self, pages: Vec<u32>, pattern: String, case_insensitive: bool) -> Result<Vec<TextHit>, PagewerkError>
pub fn looks_scanned(&self) -> bool
pub fn blank_pages(&self) -> Result<Vec<u32>, PagewerkError>
pub fn content_bounds(&self, page: u32) -> Result<Option<DisplayRect>, PagewerkError>
pub fn pages_without_text(&self) -> Result<Vec<u32>, PagewerkError>
pub fn has_form(&self) -> Result<bool, PagewerkError>
pub fn form_widgets(&self) -> Result<Vec<FormWidget>, PagewerkError>
pub fn fill_form(&self, edits: Vec<FormEdit>) -> Result<Vec<u8>, PagewerkError>
pub fn chapter_starts(&self) -> Result<Vec<u32>, PagewerkError>
pub fn export_image(&self, page: u32, dpi: f64, png: bool, quality: u8) -> Result<Vec<u8>, PagewerkError>
}Methods
open Constructor
WrongPassword when the file is encrypted and password does not open it.
static func open(bytes: Data, password: String?) throws -> PdfDocpublic static PdfDoc Open(byte[] bytes, string? password)pub fn open(bytes: Vec<u8>, password: Option<String>) -> Result<Arc<PdfDoc>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
bytes | Vec<u8> | bytes |
password | Option<String> | password |
Returns
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
page_count
No description yet.
func pageCount() -> UInt32public uint PageCount()pub fn page_count(&self) -> u32Parameters
None.
Returns
u32
Errors
Does not throw.
page_sizes
Each page as displayed, in points.
func pageSizes() -> [PageSize]public PageSize[] PageSizes()pub fn page_sizes(&self) -> Vec<PageSize>Parameters
None.
Returns
Vec<PageSize>
Errors
Does not throw.
render
The page width pixels wide; annotations: form answers, comments, stamps too.
func render(page: UInt32, width: UInt32, annotations: Bool) throws -> RenderedPagepublic RenderedPage Render(uint page, uint width, bool annotations)pub fn render(&self, page: u32, width: u32, annotations: bool) -> Result<RenderedPage, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
page | u32 | page |
width | u32 | width |
annotations | bool | annotations |
Returns
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
text
No description yet.
func text(page: UInt32) throws -> Stringpublic string Text(uint page)pub fn text(&self, page: u32) -> Result<String, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
page | u32 | page |
Returns
String
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
words
No description yet.
func words(page: UInt32) throws -> [TextWord]public TextWord[] Words(uint page)pub fn words(&self, page: u32) -> Result<Vec<TextWord>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
page | u32 | page |
Returns
Vec<TextWord>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
find
Matches of a regular expression; escape_pattern turns plain words into one.
func find(pages: [UInt32], pattern: String, caseInsensitive: Bool) throws -> [TextHit]public TextHit[] Find(uint[] pages, string pattern, bool caseInsensitive)pub fn find(&self, pages: Vec<u32>, pattern: String, case_insensitive: bool) -> Result<Vec<TextHit>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
pages | Vec<u32> | pages |
pattern | String | pattern |
case_insensitive | bool | caseInsensitive |
Returns
Vec<TextHit>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
looks_scanned
No text on the first pages: probably a scan.
func looksScanned() -> Boolpublic bool LooksScanned()pub fn looks_scanned(&self) -> boolParameters
None.
Returns
bool
Errors
Does not throw.
blank_pages
No description yet.
func blankPages() throws -> [UInt32]public uint[] BlankPages()pub fn blank_pages(&self) -> Result<Vec<u32>, PagewerkError>Parameters
None.
Returns
Vec<u32>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
content_bounds
No description yet.
func contentBounds(page: UInt32) throws -> DisplayRect?public DisplayRect? ContentBounds(uint page)pub fn content_bounds(&self, page: u32) -> Result<Option<DisplayRect>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
page | u32 | page |
Returns
Option<DisplayRect>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
pages_without_text
No description yet.
func pagesWithoutText() throws -> [UInt32]public uint[] PagesWithoutText()pub fn pages_without_text(&self) -> Result<Vec<u32>, PagewerkError>Parameters
None.
Returns
Vec<u32>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
has_form
No description yet.
func hasForm() throws -> Boolpublic bool HasForm()pub fn has_form(&self) -> Result<bool, PagewerkError>Parameters
None.
Returns
bool
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
form_widgets
Every form widget, for the app to draw controls over the rendered page.
func formWidgets() throws -> [FormWidget]public FormWidget[] FormWidgets()pub fn form_widgets(&self) -> Result<Vec<FormWidget>, PagewerkError>Parameters
None.
Returns
Vec<FormWidget>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
fill_form
Fills widgets in this open document; returns the file as it now is.
func fillForm(edits: [FormEdit]) throws -> Datapublic byte[] FillForm(FormEdit[] edits)pub fn fill_form(&self, edits: Vec<FormEdit>) -> Result<Vec<u8>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
edits | Vec<FormEdit> | edits |
Returns
Vec<u8>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
chapter_starts
Pages where a chapter (top-level bookmark) starts.
func chapterStarts() throws -> [UInt32]public uint[] ChapterStarts()pub fn chapter_starts(&self) -> Result<Vec<u32>, PagewerkError>Parameters
None.
Returns
Vec<u32>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
export_image
One page as a JPG or PNG file (PDF in Bilder).
func exportImage(page: UInt32, dpi: Double, png: Bool, quality: UInt8) throws -> Datapublic byte[] ExportImage(uint page, double dpi, bool png, byte quality)pub fn export_image(&self, page: u32, dpi: f64, png: bool, quality: u8) -> Result<Vec<u8>, PagewerkError>Parameters
| Name | Type | Swift / C# |
|---|---|---|
page | u32 | page |
dpi | f64 | dpi |
png | bool | png |
quality | u8 | quality |
Returns
Vec<u8>
Errors
Throws PagewerkError:
Unreadable: “unreadable: {message}”Refused: “refused: {message}”WrongPassword: “wrong password”
Used by
compare_documents, compare_report, pixel_changes, redact_find
Signatures are generated from the engine’s code. Swift is checked against the generated bindings; C# follows the bindings generator’s naming rules.