
Adobe Acrobat SDK
Working with Cos Objects
Developing Plug-ins and Applications
Populating a PDF document with a content stream 202
DURING
//Create a PDDoc object
NewDoc = PDDocCreate();
if (NewDoc){
//Invoke the PDDocCreatePage method
NewPage = PDDocCreatePage(NewDoc, PDBeforeFirstPage, MedBox);
if (!NewPage)
ASRaise (0);
//Invoke CreateResourceDicts
if (CreateResourceDicts(PDDocGetCosDoc(NewDoc)) == false)
ASRaise (0);
//Invoke SetResourceForPage method
result = SetResourceForPage(NewPage);
// Invoke AddStreamToPage
result = AddStreamToPage (NewPage, StreamBuf, StreamBufLen);
if (result == false)
ASRaise (0);
PDPageRelease (NewPage);
}
HANDLER
AVAlertNote ("Problem creating document.");
if (NewPage) PDPageRelease (NewPage);
if (NewDoc) PDDocClose (NewDoc);
return;
END_HANDLER
DURING
//Open the new doc
AVDocOpenFromPDDoc(NewDoc, NULL);
//Save the PDF document to the root of C and name it cosPDFDocument.pdf
PDDocSave(NewDoc, PDSaveFull | PDSaveLinearized ,ASPathFromPlatformPath
("C:\\cosPDFDocument.pdf"), NULL, NULL, NULL);
HANDLER
AVAlertNote ("Cannot open new document.");
END_HANDLER
}