Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: File system plug-in (asynchronous) (long)
Conf: (P-PDF) Developers, Msg: 53339
From: fabdev
Date: 5/29/2002 04:58 PM


I am currently developing a file system plug-in for Acrobat Reader, which has to retrieve a pdf over the Web, through a cgi application on the server. We chose to develop this plug-in because the byte-serving mechanism does not always work properly (and we found no documentation about it).

In order to have smooth performance, I chose to implement the MReadRequest callback, which receives pairs of offsets/lengths of data that will be needed by Acrobat. According to the docs, one has to call ASFilePushData with the offset, length and retrieved data, as soon as this data is available.

I encapsulated the actual retrieving of the data in an object, which handles a queue of offset/length pairs and uses a separate thread to get the data through http.

To give an idea, here is the (simplified) interface of this object:

- QueuePairs(ASInt32* pairs, ASInt32 numPairs): adds the pairs to the queue of data;
- Cancel: cancels all pending I/O and empty the queue;
- HasData: returns true is any data (pending or ready) is still in the queue
- GetData(long* offset, long* length, void** data): if any retrieved data is available, return its offset, length and data pointer, and returns true, else false

Now in MReadRequest, I simply do this:

webreader.QueuePairs(pairs, numPairs);
return 0;

The problem is now to push the data to Acrobat. If I push it from the separate thread as soon as data is available, it does not work:

MReadRequest is called first with no pairs, then with 1 pair (0, 1024). As soon as the data is pushed, another call to MReadRequest is made by Acrobat, with 4 pairs (the first one is (1024, 30000)). Then immediately the Close callback is called, and no other call is made.

I then tried to push the data from Yield instead of the separate thread:

if (webreader.HasData())
if (webreader.GetData(&offset, &length, &data))
ASFilePushData(asFile, data, offset, length);
delete [] data;
return 0;

Same result: mreadrequest called, data is pushed once, mreadrequest called again for more pairs, then immediately the file is closed.

So to be sure I moved the pushing part to mreadrequest:

webreader.QueuePairs(pairs, numPairs);
while (webreader.HasData())
if (webreader.GetData(&offset, &length, &data))
ASFilePushData(asFile, data, offset, length);
delete [] data;
return 0;

and it works!

But of course then I lose all asynchronous advantage: Acrobat has to wait for all data chunks to be retrieved to get the hand.

Has anybody had this kind of problem? Can anybody offer a hint? How/when am I supposed to push the data?

I am sorry for this rather lengthy post, but I can't think of a solution.

Best regards,
Fabrice Deville

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.