From 58c146a70d05bdfc13ae3b66f4a3e3cddfada77f Mon Sep 17 00:00:00 2001 From: Alastair Carey Date: Tue, 18 Oct 2022 20:04:10 +0100 Subject: [PATCH] Progressing #47 --- src/attachment.rs | 4 ++-- src/attachments.rs | 6 +++--- src/document.rs | 16 ++++++++-------- src/font.rs | 6 +++--- src/pdfium.rs | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/attachment.rs b/src/attachment.rs index 8d06671..3d203d8 100644 --- a/src/attachment.rs +++ b/src/attachment.rs @@ -175,13 +175,13 @@ impl<'a> PdfAttachment<'a> { /// * Use either the [PdfAttachment::save_to_writer()] or the [PdfAttachment::save_to_bytes()] functions, /// both of which are available when compiling to WASM. /// * Use the [PdfAttachment::save_to_blob()] function to save attachment data directly into a new - /// Javascript Blob object. This function is only available when compiling to WASM. + /// Javascript `Blob` object. This function is only available when compiling to WASM. #[cfg(not(target_arch = "wasm32"))] pub fn save_to_file(&self, path: &(impl AsRef + ?Sized)) -> Result<(), PdfiumError> { self.save_to_writer(&mut File::create(path).map_err(PdfiumError::IoError)?) } - /// Writes this [PdfAttachment] to a new Blob, returning the Blob. + /// Writes this [PdfAttachment] to a new `Blob`, returning the `Blob`. /// /// This function is only available when compiling to WASM. #[cfg(any(doc, target_arch = "wasm32"))] diff --git a/src/attachments.rs b/src/attachments.rs index 9758cf8..e4f8c3e 100644 --- a/src/attachments.rs +++ b/src/attachments.rs @@ -182,7 +182,7 @@ impl<'a> PdfAttachments<'a> { /// from a URL using the browser's built-in `fetch()` API. This function is only available when /// compiling to WASM. /// * Use the [PdfAttachments::create_attachment_from_blob()] function to load attachment data - /// from a Javascript File or Blob object (such as a File object returned from an HTML + /// from a Javascript `File` or `Blob` object (such as a `File` object returned from an HTML /// `` element). This function is only available when compiling to WASM. /// * Use another method to retrieve the bytes of the target attachment over the network, /// then load those bytes into Pdfium using the [PdfAttachments::create_attachment_from_bytes()] function. @@ -252,10 +252,10 @@ impl<'a> PdfAttachments<'a> { } /// Attempts to create a new [PdfAttachment] to this collection, using the given name and - /// the given Blob. Byte data from the given Blob will be embedded directly into + /// the given `Blob`. Byte data from the given `Blob` will be embedded directly into /// the containing document. An error will be returned if the given name is not /// unique in the list of attachments already present in the containing PDF document. - /// A File object returned from a FileList is a suitable Blob: + /// A `File` object returned from a `FileList` is a suitable `Blob`: /// /// ```text /// diff --git a/src/document.rs b/src/document.rs index 7bec07f..fb2cc26 100644 --- a/src/document.rs +++ b/src/document.rs @@ -16,7 +16,6 @@ use crate::utils::files::get_pdfium_file_writer_from_writer; use crate::utils::files::FpdfFileAccessExt; use std::io::Cursor; use std::io::Write; -use std::os::raw::c_int; #[cfg(not(target_arch = "wasm32"))] use std::fs::File; @@ -194,7 +193,7 @@ impl<'a> PdfDocument<'a> { /// Returns the file version of this [PdfDocument]. pub fn version(&self) -> PdfDocumentVersion { - let mut version: c_int = 0; + let mut version = 0; if self.bindings.FPDF_GetFileVersion(self.handle, &mut version) != 0 { PdfDocumentVersion::from_pdfium(version) @@ -203,18 +202,19 @@ impl<'a> PdfDocument<'a> { } } - /// Sets the file version that will be used the next time this [PdfDocument] is saved - /// using the [PdfDocument::save_to_writer()] function. + /// Sets the file version that will be used the next time this [PdfDocument] is saved. pub fn set_version(&mut self, version: PdfDocumentVersion) { self.output_version = Some(version); } /// Returns an immutable collection of all the [PdfAttachments] embedded in this [PdfDocument]. + #[inline] pub fn attachments(&self) -> &PdfAttachments { &self.attachments } /// Returns a mutable collection of all the [PdfAttachments] embedded in this [PdfDocument]. + #[inline] pub fn attachments_mut(&mut self) -> &mut PdfAttachments<'a> { &mut self.attachments } @@ -238,8 +238,8 @@ impl<'a> PdfDocument<'a> { } /// Returns a collection of all the [PdfPages] in this [PdfDocument]. - // TODO: AJRC - 26/9/22 - distinguish between immutable and mutable access to PdfPages - // as per https://github.com/ajrcarey/pdfium-render/issues/47. + // TODO: AJRC - 26/9/22 - distinguish between immutable and mutable access to PdfPages. + // Tracking issue: https://github.com/ajrcarey/pdfium-render/issues/47. #[inline] pub fn pages(&'a self) -> PdfPages<'a> { PdfPages::new(self) @@ -309,7 +309,7 @@ impl<'a> PdfDocument<'a> { /// * Use either the [PdfDocument::save_to_writer()] or the [PdfDocument::save_to_bytes()] functions, /// both of which are available when compiling to WASM. /// * Use the [PdfDocument::save_to_blob()] function to save document data directly into a new - /// Javascript Blob object. This function is only available when compiling to WASM. + /// Javascript `Blob` object. This function is only available when compiling to WASM. #[cfg(not(target_arch = "wasm32"))] pub fn save_to_file(&self, path: &(impl AsRef + ?Sized)) -> Result<(), PdfiumError> { self.save_to_writer(&mut File::create(path).map_err(PdfiumError::IoError)?) @@ -324,7 +324,7 @@ impl<'a> PdfDocument<'a> { Ok(cursor.into_inner()) } - /// Writes this [PdfDocument] to a new Blob, returning the Blob. + /// Writes this [PdfDocument] to a new `Blob`, returning the `Blob`. /// /// This function is only available when compiling to WASM. #[cfg(any(doc, target_arch = "wasm32"))] diff --git a/src/font.rs b/src/font.rs index 0efbd3d..360c8ae 100644 --- a/src/font.rs +++ b/src/font.rs @@ -402,7 +402,7 @@ impl<'a> PdfFont<'a> { /// URL using the browser's built-in `fetch()` API. This function is only available when /// compiling to WASM. /// * Use the [PdfFont::load_true_type_from_blob()] function to load font data from a - /// Javascript File or Blob object (such as a File object returned from an HTML + /// Javascript `File` or `Blob` object (such as a `File` object returned from an HTML /// `` element). This function is only available when compiling to WASM. /// * Use the [PdfFont::load_true_type_from_reader()] function to load font data from any /// valid Rust reader. @@ -481,8 +481,8 @@ impl<'a> PdfFont<'a> { } } - /// Attempts to load a TrueType font from the given Blob. - /// A File object returned from a FileList is a suitable Blob: + /// Attempts to load a TrueType font from the given `Blob`. + /// A `File` object returned from a `FileList` is a suitable `Blob`: /// /// ```text /// diff --git a/src/pdfium.rs b/src/pdfium.rs index 65d10dd..d15ddc2 100644 --- a/src/pdfium.rs +++ b/src/pdfium.rs @@ -213,7 +213,7 @@ impl Pdfium { /// URL using the browser's built-in `fetch()` API. This function is only available when /// compiling to WASM. /// * Use the [Pdfium::load_pdf_from_blob()] function to load document data from a - /// Javascript File or Blob object (such as a File object returned from an HTML + /// Javascript `File` or `Blob` object (such as a `File` object returned from an HTML /// `` element). This function is only available when compiling to WASM. /// * Use another method to retrieve the bytes of the target document over the network, /// then load those bytes into Pdfium using the [Pdfium::load_pdf_from_bytes()] function. @@ -248,7 +248,7 @@ impl Pdfium { /// URL using the browser's built-in `fetch()` API. This function is only available when /// compiling to WASM. /// * Use the [Pdfium::load_pdf_from_blob()] function to load document data from a - /// Javascript File or Blob object (such as a File object returned from an HTML + /// Javascript `File` or `Blob` object (such as a `File` object returned from an HTML /// `` element). This function is only available when compiling to WASM. /// * Use another method to retrieve the bytes of the target document over the network, /// then load those bytes into Pdfium using the [Pdfium::load_pdf_from_bytes()] function. @@ -311,8 +311,8 @@ impl Pdfium { } } - /// Attempts to open a [PdfDocument] by loading document data from the given Blob. - /// A File object returned from a FileList is a suitable Blob: + /// Attempts to open a [PdfDocument] by loading document data from the given `Blob`. + /// A `File` object returned from a `FileList` is a suitable `Blob`: /// /// ```text ///