Skip to Content

Is there a way to render intrinsic PDF thumbnails similar to the way PDPageDrawContentsToMemory renders pages?

Estimated Reading Time: 1 Minutes

A PDF document may contain thumbnail images, but they are not required.

Adobe Acrobat ignores any thumbnails it finds in a PDF, and automatically generates its own temporarily when they are needed for page viewing. It does not embed its own thumbnails in the PDF, but discards them when they are no longer needed.

The Adobe PDF Library creates thumbnails used in a PDF with the same underlying mechanism used in PDPageDrawContentsToMemory(). The one difference is that the underlying mechanism can specify an indexed RGB color space and PDPageDrawContentsToMemory() does not.

You can access the thumbnail for a page only at the COS level. From a PDPage, this would require:

CosObj cosPage = PDPageGetCosObj(pdPage);
CosObj Thumb = CosDictGet (cosPage, ASAtomFromString ("Thumb"));
if (CosObjGetType (Thumb) != CosNull)
   { /* If there is a thumbnail */
   ASStm ThumbData = CosStreamOpenStm (Thumb, cosOpenFiltered);
   ASInt32 Width = CosIntegerValue (CosDictGet (Thumb, ASAtomFromString ("Width")));
   ASInt32 Depth = CosIntegerValue (CosDictGet (Thumb, ASAtomFromString ("Height")));
   ASInt32 Size = Width * Depth * 3;
   Unsigned char   *BitMap;
    BitMap = ASMalloc (Size);
   ASStmRead (BitMap, 1, Size, ThumbData);
   ASStmClose (ThumbData);
 
   /* Do something with the bitmap */
   ASFree (BitMap);
}
Is there a way to render intrinsic PDF thumbnails similar to the way PDPageDrawContentsToMemory renders pages?
  • COMMENT