
Adobe Acrobat SDK
Working with Cos Objects
Developing Plug-ins and Applications
Populating a PDF document with a content stream 198
//Make sure that the page is valid
if (!page)
return false;
DURING
//Get a CosDoc object by using the PDPage page passed to this object
PageCosObj = PDPageGetCosObj(page);
if (CosDictKnown (PageCosObj, ASAtomFromString ("Resources") == true))
CosObjDestroy (CosDictGet (PageCosObj, ASAtomFromString ("Resources")));
//Place the ResDict object into the page's Resource Dictionary
CosDictPut (PageCosObj, ASAtomFromString ("Resources"), ResDict);
HANDLER
return false;
END_HANDLER
return true;
} /* end of SetResourceForPage*/
/*
** Create the font’s resources. Return true if all is valid, else false.
** Creates the required font and proc set dictionaries; then creates the
** global resource dictionary for the PDF page
*/
ASBool CreateResourceDicts (CosDoc cd)
{
DURING
ResDict = CosNewDict (cd, true, 10);
HANDLER
AVAlertNote("Trying to create the resource dictionary.");
return false;
END_HANDLER
DURING
FontDictObj = CosNewDict (cd, true, 5);
HANDLER
AVAlertNote ("Trying to create the font’s dictionary.");
CosObjDestroy (ResDict);
return false;
END_HANDLER
/* Create this font descriptor dictionary.
** <<
** /Type /Font
** /Subtype /Type1
** /Name /F0
** /BaseFont /Courier
** /Encoding /WinAnsiEncoding
** >>
*/
DURING
CosDictPut (FontDictObj, ASAtomFromString ("Type"),
CosNewName (cd, false, ASAtomFromString ("Font")));