Commit fd13fe74ef9ec7ae4a02ac59e2cd0414958adfb1
1 parent
f8e4b616
TODO and comments item for pipeContentStreams
Showing
3 changed files
with
30 additions
and
2 deletions
TODO
| ... | ... | @@ -10,6 +10,23 @@ Candidates for upcoming release |
| 10 | 10 | |
| 11 | 11 | * See if we can work in Windows Build/External Libraries (below) |
| 12 | 12 | |
| 13 | +* QPDFObjectHandle::pipeContentStreams calls finish() after each | |
| 14 | + stream. In some code paths, Pl_Concatenate is used, which suppresses | |
| 15 | + that, but in other code paths, it's not used, and the library relies | |
| 16 | + on the behavior of finish() being called. Then there's the issue of | |
| 17 | + nested Pl_Concatenate pipelines -- calling manualFinish() on the top | |
| 18 | + one doesn't call manualFinish() on the lower ones, and there are no | |
| 19 | + exposed methods that allow us to apply things down the pipeline | |
| 20 | + stack, so it's hard to fix this without changing the API (at least | |
| 21 | + making Pipeline::getNext() public, which may be undesirable). To see | |
| 22 | + this problem in action, stick a Pl_Concatenate in front of the | |
| 23 | + pipeline in pipeContentStreams and observe the test failure. One | |
| 24 | + solution might be to add an additional argument indicating whether | |
| 25 | + or not to delay calling finish() until the end. See comments on | |
| 26 | + QPDFPageObjectHelper::filterPageContents, | |
| 27 | + QPDFObjectHandle::filterPageContents, and | |
| 28 | + QPDFObjectHandle::pipeContentStreams | |
| 29 | + | |
| 13 | 30 | * Remember to check work `qpdf` project for private issues |
| 14 | 31 | * file with very slow page extraction |
| 15 | 32 | * big page even with --remove-unreferenced-resources=yes, even with --empty | ... | ... |
include/qpdf/QPDFObjectHandle.hh
| ... | ... | @@ -393,7 +393,12 @@ class QPDFObjectHandle |
| 393 | 393 | // messages. The all_description argument is initialized to |
| 394 | 394 | // something that could be used to describe the result of the |
| 395 | 395 | // pipeline. It is the description amended with the identifiers of |
| 396 | - // the underlying objects. | |
| 396 | + // the underlying objects. Please note that if there is an array | |
| 397 | + // of content streams, p->finish() is called after each stream. If | |
| 398 | + // you pass a pipeline that doesn't allow write() to be called | |
| 399 | + // after finish(), you can wrap it in an instance of | |
| 400 | + // Pl_Concatenate and then call manualFinish() on the | |
| 401 | + // Pl_Concatenate pipeline at the end. | |
| 397 | 402 | QPDF_DLL |
| 398 | 403 | void pipeContentStreams(Pipeline* p, std::string const& description, |
| 399 | 404 | std::string& all_description); |
| ... | ... | @@ -419,6 +424,7 @@ class QPDFObjectHandle |
| 419 | 424 | void parsePageContents(ParserCallbacks* callbacks); |
| 420 | 425 | QPDF_DLL |
| 421 | 426 | void filterPageContents(TokenFilter* filter, Pipeline* next = 0); |
| 427 | + // See comments for QPDFPageObjectHelper::pipePageContents. | |
| 422 | 428 | QPDF_DLL |
| 423 | 429 | void pipePageContents(Pipeline* p); |
| 424 | 430 | QPDF_DLL | ... | ... |
include/qpdf/QPDFPageObjectHelper.hh
| ... | ... | @@ -145,7 +145,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper |
| 145 | 145 | |
| 146 | 146 | // Pipe a page's contents through the given pipeline. This method |
| 147 | 147 | // works whether the contents are a single stream or an array of |
| 148 | - // streams. Call on a page object. | |
| 148 | + // streams. Call on a page object. Please note that if there is an | |
| 149 | + // array of content streams, p->finish() is called after each | |
| 150 | + // stream. If you pass a pipeline that doesn't allow write() to be | |
| 151 | + // called after finish(), you can wrap it in an instance of | |
| 152 | + // Pl_Concatenate and then call manualFinish() on the | |
| 153 | + // Pl_Concatenate pipeline at the end. | |
| 149 | 154 | QPDF_DLL |
| 150 | 155 | void pipePageContents(Pipeline* p); |
| 151 | 156 | ... | ... |