#[derive(Debug, Clone)]
pub struct TextOptions {
pub x_tolerance: f32,
pub y_tolerance: f32,
pub x_tolerance_ratio: Option<f32>,
pub x_density: f32,
pub y_density: f32,
pub keep_blank_chars: bool,
pub use_text_flow: bool,
pub expand_ligatures: bool,
}
impl TextOptions {
pub fn pdfplumber_defaults() -> Self {
Self {
x_tolerance: 3.0,
y_tolerance: 3.0,
x_tolerance_ratio: None,
x_density: 7.25,
y_density: 13.0,
keep_blank_chars: false,
use_text_flow: false,
expand_ligatures: false,
}
}
pub fn builder() -> TextOptionsBuilder {
TextOptionsBuilder {
inner: Self::pdfplumber_defaults(),
}
}
}
impl Default for TextOptions {
fn default() -> Self {
Self::pdfplumber_defaults()
}
}
#[derive(Debug, Clone)]
pub struct TextOptionsBuilder {
inner: TextOptions,
}
impl TextOptionsBuilder {
pub fn x_tolerance(mut self, v: f32) -> Self {
self.inner.x_tolerance = v;
self
}
pub fn y_tolerance(mut self, v: f32) -> Self {
self.inner.y_tolerance = v;
self
}
pub fn x_tolerance_ratio(mut self, v: Option<f32>) -> Self {
self.inner.x_tolerance_ratio = v;
self
}
pub fn x_density(mut self, v: f32) -> Self {
self.inner.x_density = v;
self
}
pub fn y_density(mut self, v: f32) -> Self {
self.inner.y_density = v;
self
}
pub fn keep_blank_chars(mut self, v: bool) -> Self {
self.inner.keep_blank_chars = v;
self
}
pub fn use_text_flow(mut self, v: bool) -> Self {
self.inner.use_text_flow = v;
self
}
pub fn expand_ligatures(mut self, v: bool) -> Self {
self.inner.expand_ligatures = v;
self
}
pub fn build(self) -> TextOptions {
self.inner
}
}