Skip to main content
Mar 14, 2018 10:22 PM UTC
Answered

Perform Action on PDDoc

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 is closed to new replies. Start a new post to keep the conversation going.
Test Screen NameCorrect answer
Legend
Mar 15, 2018 12:02 AM UTC

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
Mar 15, 2018 12:02 AM UTC

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.

Translate
Legend
Mar 14, 2018 11:10 PM UTC

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

Translate
Legend
Mar 14, 2018 10:43 PM UTC

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.

Translate