Can't save small files for Fast Web View?

Q:

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?

A:

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:




~


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




~


|

  • |