Can't save small files for Fast Web View?

Skip to first unread message


Oct 10, 2013, 11:09:44 AM10/10/13

I'm required to save all documents with property 'Fast Web View' set to 'Yes'.  I am using the following code:

doc.GetSDFDoc().Save(path, SDFDoc.SaveOptions.e_compatibility | SDFDoc.SaveOptions.e_linearized | SDFDoc.SaveOptions.e_remove_unused, NULL, header);

This works for most documents, but for very small files, Acrobat still shows 'Fast Web View' set to 'No'.  What's going on?



We've determined that Acrobat will not recognize files below 4 KB in size as being optimized for 'Fast Web View', even though they are correctly linearized according to the specification.  In fact, when Acrobat saves these small files for 'Fast Web View', it simply adds enough padding to the file to exceed that threshold.

In practice, this is not a big problem, because such small files will not benefit much from 'Fast Web View'.  Increasing the file size is counter productive, since it may increase the download time for the document.  If you do want to replicate Acrobat's behaviour, you can add a dummy stream to the document like this:

PDFDoc doc("small_doc.pdf");
std::vector<char> dummy_buf;
dummy_buf.resize(4096); // you can write whatever data you would like here - garbage, white space, or a poem are all good choices.
SDF::Obj * dummy_stm = doc.CreateIndirectStream(&dummy_buf[0], 4096);
SDF::Obj * root = doc.GetRoot();
root->Put("Adobe Workaround", dummy_stm);
doc.GetSDFDoc()->Save("fast_web_view.pdf", SDF::SDFDoc::e_compatibility | SDF::SDFDoc::e_linearized | SDF::SDFDoc::e_remove_unused, NULL, doc.GetSDFDoc()->GetHeader());

Reply all
Reply to author
0 new messages