Is there a way to render intrinsic PDF thumbnails similar to the way PDPageDrawContentsToMemory renders pages?
Estimated Reading Time: 1 MinutesA 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.
We can see thousands of different shades of colors, and high-quality digital cameras and scanners can often detect millions of shades. To manage the broad range of colors for producing graphics images in digital content, imaging professionals have developed models to define these colors, called color spaces.
Many color spaces have been defined. Some are dependent on hardware devices, and define what a camera can detect, or a printer print, or a monitor display. Others are based on software and thus can be used across many different kinds of devices, such as Adobe RGB or sRGB (standard RGB). A color space must be defined for any device or software product in order to make sure that coloring patterns remain the same from one device or system to another.
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); }