Skip to main content
March 14, 2018
Answered

Perform Action on PDDoc

  • March 14, 2018
  • 3 replies
  • 886 views

Hi all,

comming from thread Re: Acrobat not releasing files, AV_Layer, AVDocDoSave(), AVDocClose()  I'd like to clarify how I can work on the PDDoc API.

My aim is to perform an OCR on a given document. To do so I've tried for example:

ASAtom pathType = ASAtomFromString(
  
"Cstring");
ASFileSys fileSys = ASGetDefaultFileSysForPath(pathType,
  
"C:/_TRANSFER/a4.pdf");
ASPathName pathLaunchFile = ASFileSysCreatePathName(fileSys, pathType,
  
"C:/_TRANSFER/a4.pdf", NULL);
// AVDoc avDoc = AVDocOpenFromFile(pathLaunchFile, fileSys, NULL);
// PDDoc pdDoc = AVDocGetPDDoc(avDoc);


PDDoc pdDoc = PDDocOpen(pathLaunchFile, fileSys, false, false);

PDAction myAct1 = PDActionNew(pdDoc, ASAtomFromString("PaperCapture"));
CosObj  onObj = PDActionGetCosObj(myAct1);
CosDoc cosDoc = CosObjGetDoc(onObj);
PDDoc pdDocNew = PDDocFromCosDoc(cosDoc);

PDSaveFlags pdsaveflags = PDSaveFlags();
ASProgressMonitor asProgressMonitor = ASProgressMonitor();
PDDocSave(pdDocNew, pdsaveflags, pathLaunchFile, fileSys, asProgressMonitor, false);
PDDocClose(pdDoc);
PDDocRelease(pdDoc);

But this seems to be not working at all since the file is obviously updated (new timestamp) - even with a larger filesize, but not OCR is performed (tested by search for Words, which are available after a manual OCR).

Any suggestions? 😃

Cheers,

S.

This topic has been closed for replies.
Correct answer Test Screen Name

AVCommand is a rich, complex, API with documentation that is very short on instructions, but not incomplete. It's years since I used it but I do remember it took weeks and weeks of careful analysis and experiment. Have you carefully read all of the AVCommand documentation? It is many years since I used it but it looks to me as if PDDoc is accepted as input, even if some AVCommandHandlers may not function with one.

3 replies

Test Screen NameCorrect answer
Legend
March 15, 2018

AVCommand is a rich, complex, API with documentation that is very short on instructions, but not incomplete. It's years since I used it but I do remember it took weeks and weeks of careful analysis and experiment. Have you carefully read all of the AVCommand documentation? It is many years since I used it but it looks to me as if PDDoc is accepted as input, even if some AVCommandHandlers may not function with one.

Legend
March 14, 2018

AVCommand seems the only possibility. Are you sure it doesn’t allow PDDoc source too?

Legend
March 14, 2018

I think you have the wrong idea of what a PDAction is. It is nothing to do with commands/automation. maybe you want AVCommand though I’m not sure OCR can be automated.