Skip to content

feat: add feature flags - #83

Merged
AstraBert merged 3 commits into
mainfrom
feat/feature-flagging
Jul 1, 2026
Merged

AstraBert merged 3 commits into
mainfrom
feat/feature-flagging

Conversation

@AstraBert

Copy link
Copy Markdown
Owner
  • chore: feature flagging
  • feat: add feature flags

@dosubot

dosubot Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

📄 Knowledge review

✏️ Suggested updates

1 page suggestion needs review.

Page Library Status
PdfItdown Converter Clelia's Org's Space ✅ Accepted
📝 PdfItdown Converter
@@ -8,22 +8,58 @@
 
 The `PdfItDownConverter` provides a single interface for converting files and directories to PDF. It supports both file paths and in-memory data, and routes each input to the appropriate specialized converter based on file format.
 
+## Feature Flags
+
+PdfItDown uses Cargo features to let you choose which converters to include:
+
+| Feature | Description | Default |
+|---------|-------------|---------|
+| `cli` | Enables the command-line interface and `clap` dependency | ✅ |
+| `image` | Enables image-to-PDF conversion (`png`, `jpg`, etc.) | ✅ |
+| `office` | Enables Office document conversion (`docx`, `xlsx`, `pptx`) | ✅ |
+| `markup` | Enables Markdown/HTML conversion and text-based formats | ✅ |
+| `rayon` | Enables parallelized batch conversion | ❌ |
+
+Each converter is only available when its corresponding feature is enabled:
+
+- `ImageConverter` requires the `image` feature
+- `OfficeConverter` requires the `office` feature
+- `MarkupConverter` and `TextConverter` require the `markup` feature
+
+**Examples:**
+
+```toml
+# Library only, no CLI
+[dependencies]
+pdfitdown = { version = "4.0", default-features = false, features = ["markup", "image"] }
+
+# All converters + parallelization
+[dependencies]
+pdfitdown = { version = "4.0", features = ["rayon"] }
+
+# Minimal markup-only configuration
+[dependencies]
+pdfitdown = { version = "4.0", default-features = false, features = ["markup"] }
+```
+
 ## Supported Formats
 
-- **Images**: PNG, JPG, JPEG, AVIF, TIFF, WEBP
-- **Office Documents**: DOCX, XLSX, PPTX
-- **Markup**: Markdown, HTML
-- **Text/Code**: TXT, JSON, CSV, XML, and many code formats (Rust, Python, JavaScript, TypeScript, etc.)
+The following formats are supported when their corresponding features are enabled:
+
+- **Images** (`image` feature): PNG, JPG, JPEG, AVIF, TIFF, WEBP
+- **Office Documents** (`office` feature): DOCX, XLSX, PPTX
+- **Markup** (`markup` feature): Markdown, HTML
+- **Text/Code** (`markup` feature): TXT, JSON, CSV, XML, and many code formats (Rust, Python, JavaScript, TypeScript, etc.)
 - **PDF**: Pass-through (no conversion)
 
 ## Core Architecture
 
-The converter is organized into specialized modules, each implementing the `Converter` trait:
-
-- `crates/pdfitdown/src/img/mod.rs` - image conversion using the `image` crate
-- `crates/pdfitdown/src/office/mod.rs` - office document conversion via `office2pdf`
-- `crates/pdfitdown/src/markup/mod.rs` - markup conversion using `markdown2pdf`
-- `crates/pdfitdown/src/text/mod.rs` - text and code file conversion
+The converter is organized into specialized modules, each implementing the `Converter` trait. Modules are conditionally compiled based on feature flags:
+
+- `crates/pdfitdown/src/img/mod.rs` - image conversion using the `image` crate (`image` feature)
+- `crates/pdfitdown/src/office/mod.rs` - office document conversion via `office2pdf` (`office` feature)
+- `crates/pdfitdown/src/markup/mod.rs` - markup conversion using `markdown2pdf` (`markup` feature)
+- `crates/pdfitdown/src/text/mod.rs` - text and code file conversion (`markup` feature)
 - `crates/pdfitdown/src/types.rs` - type definitions including `ConversionInput` and the `Converter` trait
 
 ## Usage in Rust
@@ -81,7 +117,7 @@
 )?;
 ```
 
-Can be parallelized with the `rayon` feature enabled.
+Parallelization is available when the `rayon` feature is enabled.
 
 ### `convert_directory`
 
@@ -170,7 +206,7 @@
 
 ## CLI Integration
 
-The PdfItDown CLI uses the `PdfItDownConverter` to provide commands for converting files and directories to PDF. You can specify input files, output files, and directories directly from the command line. The CLI supports both single and batch conversions, with optional overwrite control and recursive directory conversion.
+The PdfItDown CLI uses the `PdfItDownConverter` to provide commands for converting files and directories to PDF. The CLI requires the `cli` feature, which is enabled by default. You can specify input files, output files, and directories directly from the command line. The CLI supports both single and batch conversions, with optional overwrite control and recursive directory conversion.
 
 [See the CLI implementation.](https://github.com/AstraBert/PdfItDown/blob/main/crates/pdfitdown/src/main.rs)
 

✅ Accepted


Leave Feedback Ask Dosu about PdfItDown Add Dosu to your team

@AstraBert
AstraBert merged commit dcff482 into main Jul 1, 2026
45 checks passed
@AstraBert
AstraBert deleted the feat/feature-flagging branch July 1, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant