Skip to content

Commit

Permalink
Progressing #47
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastair Carey committed Oct 18, 2022
1 parent b140d3f commit 58c146a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path> + ?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"))]
Expand Down
6 changes: 3 additions & 3 deletions src/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// `<input type="file">` 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.
Expand Down Expand Up @@ -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
/// <input id="filePicker" type="file">
Expand Down
16 changes: 8 additions & 8 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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<Path> + ?Sized)) -> Result<(), PdfiumError> {
self.save_to_writer(&mut File::create(path).map_err(PdfiumError::IoError)?)
Expand All @@ -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"))]
Expand Down
6 changes: 3 additions & 3 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// `<input type="file">` 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.
Expand Down Expand Up @@ -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
/// <input id="filePicker" type="file">
Expand Down
8 changes: 4 additions & 4 deletions src/pdfium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// `<input type="file">` 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.
Expand Down Expand Up @@ -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
/// `<input type="file">` 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.
Expand Down Expand Up @@ -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
/// <input id="filePicker" type="file">
Expand Down

0 comments on commit 58c146a

Please sign in to comment.