galkahana/PDF-Writer — pull request #23 by filodej (2014-10-02 16:38:58+00:00)
Title: Pdf page content transfer

Hi Gal,
I have prepared another extension of your (great) library.

What I am trying to achieve is some kind of content filtering. Maybe I am missing something, but it seems to me that a hook for such kind of customization was missing.

I have extended the `IPDFParserExtender` for that purpose - now it can provide a `TransferContent()` method.
For convenience I provided a `IPDFParserExtenderAdapter` providing default "do nothing" implementations of all interface methods. As there was no such adapter before, I did not dare to make the two new interface methods pure virtual not to break clients' code.

Then I have created a trivial implementation of the `AbstractContentContext` interface on top of just `IByteWriter` and `ResourcesDictionary` - `WriterContentContext`.

The `ContentTransferExtenderPDF` demonstrates how all the created stuff can be utilized. As a sample input PDF I have added the *Bible de Genève, 1564* available as a demo for the [pdf2htmlEX library](https://github.com/coolwanglu/pdf2htmlEX).

It is admittedly a half baked solution right now, so I'll take no offense if you reject it.
There is no posibility to add any new resources in the `TransferContent()` hook - the `PDFDocumentHandler::OnResourcesWrite()` method assumes there are no new resources created - all possibly created resources are collected in local `ResourcesDictionary` and finally thrown away. But at least the current solution can be used for some kind of data mining, or content filtering.

In future I would like to utilize this hook for some content tokenization and parsing/filtering, something like the following code:
https://gist.github.com/filodej/38d88c248929bc8254bd

Please, let me know what you think, or possibly give me valuable advices how to deal with resources.

Kind regards,
Petr