pub struct Redactor { /* private fields */ }Expand description
Two-phase redactor: mark areas, then apply.
Implementations§
Source§impl Redactor
impl Redactor
Sourcepub fn mark(&mut self, area: RedactionArea)
pub fn mark(&mut self, area: RedactionArea)
Mark an area for redaction.
Sourcepub fn mark_all(&mut self, areas: impl IntoIterator<Item = RedactionArea>)
pub fn mark_all(&mut self, areas: impl IntoIterator<Item = RedactionArea>)
Mark multiple areas for redaction.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Return the number of pending redaction areas.
Sourcepub fn apply(&self, doc: &mut Document) -> Result<RedactionReport>
pub fn apply(&self, doc: &mut Document) -> Result<RedactionReport>
Apply all pending redactions to the document.
This permanently removes content in the marked areas, draws overlay rectangles, and cleans document metadata.
Each area is in the page’s default user space (the coordinate system
of the page’s content before any cm). Content counts as under an
area where it is drawn, after the current transformation matrix, the
text matrix and any Form XObject /Matrix have been applied:
- glyphs under an area are removed one by one; the glyphs around them keep their positions;
- a path that touches an area is removed whole (a clipping path keeps its clip and loses only its painting);
- an image or inline image that touches an area is replaced by a black image of the same placement;
- a Form XObject under an area is filtered the same way. A form that is also drawn elsewhere is copied first, so other pages and other placements keep the original;
- replacement text (
/ActualText,/Alt,/E) on marked content that lost something is removed with it.
Objects the rewrite no longer uses are dropped, so a full save writes none of the removed content. An incremental save would keep the earlier revision: save the result with a full rewrite.
§Errors
Returns an error, and leaves doc unchanged, when a redacted page
contains something the filter cannot place: text in a Type3 font,
vertical writing, a content stream it cannot decode or parse, a Form
XObject that draws itself, or an image in a filter listed under
RedactError::UnsupportedImageFilter. It never reports success over
content it did not process.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Redactor
impl RefUnwindSafe for Redactor
impl Send for Redactor
impl Sync for Redactor
impl Unpin for Redactor
impl UnsafeUnpin for Redactor
impl UnwindSafe for Redactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().