#![allow(clippy::all)]
pub mod actions;
pub mod advanced_tables;
pub mod ai;
pub mod annotations;
pub mod batch;
pub mod charts;
pub mod compression;
pub mod coordinate_system;
pub mod document;
pub mod encryption;
pub mod error;
pub mod fonts;
pub mod forms;
pub mod geometry;
pub mod graphics;
pub mod memory;
pub mod metadata;
pub mod objects;
pub mod operations;
pub mod page;
pub mod page_forms;
pub mod page_labels;
pub mod page_lists;
pub mod page_tables;
pub mod page_transitions;
pub mod page_tree;
pub mod parser;
pub mod pdf_objects;
pub mod pdfa;
#[cfg(feature = "performance")]
pub mod performance;
pub mod pipeline;
pub mod recovery;
pub mod streaming;
pub mod structure;
pub mod templates;
pub mod text;
pub mod verification;
pub mod viewer_preferences;
pub mod writer;
pub mod semantic;
pub mod signatures;
pub mod dashboard;
pub use coordinate_system::{CoordinateSystem, RenderContext, TransformMatrix};
pub use document::{Document, DocumentMetadata};
pub use error::{OxidizePdfError, PdfError, Result};
pub use geometry::{Point, Rectangle};
pub use graphics::{Color, ColorSpace, GraphicsContext, Image, ImageFormat, MaskType};
pub use page::{Margins, Page};
pub use page_lists::{ListStyle, ListType, PageLists};
pub use page_tables::{PageTables, TableStyle};
pub use text::{
measure_text,
split_into_words,
BulletStyle,
Font,
FontFamily,
FragmentType,
HeaderStyle,
ImagePreprocessing,
ListElement,
ListOptions,
MockOcrProvider,
OcrEngine,
OcrError,
OcrOptions,
OcrProcessingResult,
OcrProvider,
OcrResult,
OcrTextFragment,
OrderedList,
OrderedListStyle,
Table,
TableCell,
TableOptions,
TextAlign,
TextContext,
TextFlowContext,
UnorderedList,
};
pub use forms::{
calculations::FieldValue,
field_actions::{
ActionSettings, FieldAction, FieldActionSystem, FieldActions, FormatActionType,
SpecialFormatType, ValidateActionType,
},
validation::{
DateFormat, FieldValidator, FormValidationSystem, FormatMask, PhoneCountry,
RequiredFieldInfo, RequirementCondition, TimeFormat, ValidationRule, ValidationSettings,
},
BorderStyle, FieldType, TextField, Widget,
};
pub use text::fonts::embedding::{
EmbeddedFontData, EmbeddingOptions, EncodingDifference, FontDescriptor, FontEmbedder,
FontEncoding, FontFlags, FontMetrics, FontType,
};
pub use text::font_manager::{CustomFont, FontManager};
pub use parser::{
ContentOperation, ContentParser, DocumentMetadata as ParsedDocumentMetadata, ParseOptions,
ParsedPage, PdfArray, PdfDictionary, PdfDocument, PdfName, PdfObject, PdfReader, PdfStream,
PdfString,
};
pub use operations::{
extract_images_from_pages, extract_images_from_pdf, merge_pdfs, move_pdf_page, overlay_pdf,
reorder_pdf_pages, reverse_pdf_pages, rotate_pdf_pages, split_pdf, swap_pdf_pages,
ExtractImagesOptions, ExtractedImage, ImageExtractor, OverlayOptions, OverlayPosition,
ReorderOptions,
};
pub use dashboard::{
Dashboard, DashboardBuilder, DashboardComponent, DashboardConfig, DashboardLayout,
DashboardTheme, HeatMap, KpiCard, PivotTable, ScatterPlot, TreeMap, Typography,
};
pub use memory::{LazyDocument, MemoryOptions, StreamProcessor, StreamingOptions};
pub use streaming::{
process_in_chunks, stream_text, ChunkOptions, ChunkProcessor, ChunkType, ContentChunk,
IncrementalParser, ParseEvent, StreamingDocument, StreamingOptions as StreamOptions,
StreamingPage, TextChunk, TextStreamOptions, TextStreamer,
};
pub use batch::{
batch_merge_pdfs, batch_process_files, batch_split_pdfs, BatchJob, BatchOptions,
BatchProcessor, BatchProgress, BatchResult, BatchSummary, JobResult, JobStatus, JobType,
ProgressCallback, ProgressInfo,
};
pub use recovery::{
analyze_corruption, detect_corruption, quick_recover, repair_document, validate_pdf,
CorruptionReport, CorruptionType, ObjectScanner, PartialRecovery, PdfRecovery, RecoveredPage,
RecoveryOptions, RepairResult, RepairStrategy, ScanResult, ValidationError, ValidationResult,
};
pub use structure::{
Destination, DestinationType, NameTree, NameTreeNode, NamedDestinations, OutlineBuilder,
OutlineItem, OutlineTree, PageDestination, PageTree, PageTreeBuilder, PageTreeNode,
};
pub use actions::{
Action, ActionDictionary, ActionType, GoToAction, LaunchAction, LaunchParameters, NamedAction,
RemoteGoToAction, StandardNamedAction, UriAction, UriActionFlags,
};
pub use page_labels::{PageLabel, PageLabelBuilder, PageLabelRange, PageLabelStyle, PageLabelTree};
pub use templates::{
Template, TemplateContext, TemplateError, TemplateRenderer, TemplateResult, TemplateValue,
};
pub use semantic::{
BoundingBox, Entity, EntityMap, EntityMetadata, EntityRelation, EntityType, ExportFormat,
RelationType, SemanticEntity, SemanticMarking,
};
pub use verification::comparators::{
compare_pdfs, ComparisonResult, DifferenceSeverity, PdfDifference,
};
pub use verification::compliance_report::{
format_report_markdown, generate_compliance_report, ComplianceReport,
};
pub use verification::iso_matrix::{load_default_matrix, load_matrix, ComplianceStats, IsoMatrix};
pub use verification::validators::{
check_available_validators, validate_external, validate_with_qpdf,
};
pub use verification::{
extract_pdf_differences, pdfs_structurally_equivalent, verify_iso_requirement,
ExternalValidationResult, IsoRequirement, VerificationLevel, VerificationResult,
};
pub use pdfa::{
PdfAConformance, PdfAError, PdfALevel, PdfAResult, PdfAValidator,
ValidationError as PdfAValidationError, ValidationResult as PdfAValidationResult,
ValidationWarning as PdfAValidationWarning, XmpMetadata, XmpPdfAIdentifier,
};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub mod pdf_version {
pub const SUPPORTED_VERSIONS: &[&str] =
&["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7"];
pub const PLANNED_VERSIONS: &[&str] = &["2.0"];
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_create_empty_document() {
let doc = Document::new();
assert_eq!(doc.pages.len(), 0);
}
#[test]
fn test_create_page() {
let page = Page::new(595.0, 842.0);
assert_eq!(page.width(), 595.0);
assert_eq!(page.height(), 842.0);
}
#[test]
fn test_version_info() {
assert!(!VERSION.is_empty());
assert!(pdf_version::SUPPORTED_VERSIONS.contains(&"1.7"));
}
#[test]
fn test_pdf_version_constants() {
let expected_versions = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7"];
for version in expected_versions {
assert!(
pdf_version::SUPPORTED_VERSIONS.contains(&version),
"Expected PDF version {version} to be supported"
);
}
assert_eq!(pdf_version::SUPPORTED_VERSIONS.len(), 8);
assert!(pdf_version::PLANNED_VERSIONS.contains(&"2.0"));
assert_eq!(pdf_version::PLANNED_VERSIONS.len(), 1);
}
#[test]
fn test_document_with_metadata() {
let mut doc = Document::new();
doc.set_title("Test Document");
doc.set_author("Test Author");
doc.set_subject("Test Subject");
assert_eq!(doc.pages.len(), 0);
}
#[test]
fn test_page_creation_variants() {
let page_a4 = Page::a4();
let page_letter = Page::letter();
let page_custom = Page::new(400.0, 600.0);
assert!((page_a4.width() - 595.0).abs() < 10.0);
assert!((page_a4.height() - 842.0).abs() < 10.0);
assert_eq!(page_letter.width(), 612.0);
assert_eq!(page_letter.height(), 792.0);
assert_eq!(page_custom.width(), 400.0);
assert_eq!(page_custom.height(), 600.0);
}
#[test]
fn test_color_creation() {
let red = Color::rgb(1.0, 0.0, 0.0);
let green = Color::rgb(0.0, 1.0, 0.0);
let blue = Color::rgb(0.0, 0.0, 1.0);
let black = Color::rgb(0.0, 0.0, 0.0);
let white = Color::rgb(1.0, 1.0, 1.0);
let _colors = [red, green, blue, black, white];
let cyan = Color::cmyk(1.0, 0.0, 0.0, 0.0);
let _cmyk_test = cyan;
}
#[test]
fn test_font_types() {
let helvetica = Font::Helvetica;
let times = Font::TimesRoman;
let courier = Font::Courier;
let _fonts = [helvetica, times, courier];
let helvetica_family = FontFamily::Helvetica;
let times_family = FontFamily::Times;
let courier_family = FontFamily::Courier;
let _families = [helvetica_family, times_family, courier_family];
}
#[test]
fn test_error_types() {
let pdf_error = PdfError::InvalidStructure("test error".to_string());
let _error_test = pdf_error;
let ok_result: Result<i32> = Ok(42);
let err_result: Result<i32> = Err(PdfError::InvalidStructure("test error".to_string()));
assert!(ok_result.is_ok());
assert!(err_result.is_err());
}
#[test]
fn test_module_exports() {
let _doc = Document::new();
let _page = Page::new(100.0, 100.0);
let _color = Color::rgb(0.5, 0.5, 0.5);
let _font = Font::Helvetica;
let _array = PdfArray::new();
let _dict = PdfDictionary::new();
let _name = PdfName::new("Test".to_string());
let _string = PdfString::new(b"Test".to_vec());
let _margins = Margins {
top: 10.0,
right: 10.0,
bottom: 10.0,
left: 10.0,
};
let _align = TextAlign::Left;
}
#[test]
fn test_ocr_types() {
let _mock_ocr = MockOcrProvider::new();
let _ocr_options = OcrOptions::default();
let _ocr_engine = OcrEngine::Tesseract;
let _fragment_type = FragmentType::Word;
let _image_preprocessing = ImagePreprocessing::default();
}
#[test]
fn test_text_utilities() {
let text = "Hello world test";
let words = split_into_words(text);
assert!(!words.is_empty());
assert!(words.contains(&"Hello"));
assert!(words.contains(&"world"));
let font = Font::Helvetica;
let size = 12.0;
let width = measure_text(text, &font, size);
assert!(width > 0.0);
}
#[test]
fn test_image_types() {
let _format = ImageFormat::Jpeg;
let _color_space = ColorSpace::DeviceRGB;
let image_data = vec![0u8; 100];
let _image = Image::from_jpeg_data(image_data);
}
#[test]
fn test_version_string_format() {
let version_parts: Vec<&str> = VERSION.split('.').collect();
assert!(
version_parts.len() >= 2,
"Version should have at least major.minor format"
);
assert!(
version_parts[0].parse::<u32>().is_ok(),
"Major version should be numeric"
);
assert!(
version_parts[1].parse::<u32>().is_ok(),
"Minor version should be numeric"
);
assert!(!VERSION.is_empty());
assert!(!VERSION.is_empty());
}
}