Add comprehensive stream-based API to DocumentOperation functionality#1275
Draft
Add comprehensive stream-based API to DocumentOperation functionality#1275
Conversation
Co-authored-by: MarcinZiabek <9263853+MarcinZiabek@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve the DocumentOperation functionality by providing stream-based instead of file-based API
Add comprehensive stream-based API to DocumentOperation functionality
Jun 27, 2025
|
@MarcinZiabek When can we expect this PR to be merged? We are currently blocked, and not sure if we should await this PR being merged or look for other alternatives. Thanks. |
|
We are highly interested in this feature as well |
|
We are also very interested in this feature. Is there a possibility of integrating it soon? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a complete stream-based API for DocumentOperation alongside the existing file-based API, providing developers with flexible options for PDF manipulation scenarios.
New Stream-Based Methods
Loading and Saving
LoadStream(Stream, password)- Load PDF from a stream instead of file pathSaveToStream(Stream)- Save processed PDF directly to a streamMerging and Processing
MergeStream(Stream, pageSelector)- Merge PDF content from streamsOverlayStream(LayerStreamConfiguration)- Apply overlay content from streamsUnderlayStream(LayerStreamConfiguration)- Apply underlay content from streamsAddAttachmentStream(DocumentAttachmentStream)- Add file attachments from streamsKey Features
✅ Full backward compatibility - All existing file-based APIs remain unchanged
✅ Mixed operations - Can combine file and stream operations in the same workflow
✅ Automatic resource management - Temporary files are created and cleaned up automatically
✅ Comprehensive testing - 20 total tests (13 existing + 7 new stream tests)
✅ Rich documentation - Includes practical examples and usage patterns
Usage Examples
Basic Stream Processing
Merging Multiple Streams
Mixed File and Stream Operations
Stream-Based Attachments
Technical Implementation
The implementation uses temporary files to bridge the stream-based API with the underlying QPDF native library, which operates on file paths. Key technical features:
Fixes #1172.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.