Hi there,
From my Reader-Enabled Plugin, I am trying to save a copy of a document to the user's temporary directory using PDDocSaveWithParams
This works fine, about 90% of the time. The other 10% I get either a 0byte file or a file of very small size (i.e. 275 bytes instead of 81.4kB)
This occurs in Reader with Protected mode either on or off. Using PDDocSave returns "An Unimplemented or Obsolete function was called".
I am at a loss as to why this happens only every now and then, I have tested on multiple machines with the same result.
Code below, saveFilePath points to the users temp directory.
ASFile asFile = PDDocGetFile(doc);
ASFileSys fileSys = ASGetDefaultFileSysForPath(ASAtomFromString("Cstring"), saveFilePath);
ASPathName pathName = ASFileSysCreatePathName(fileSys, ASAtomFromString("Cstring"), saveFilePath, NULL);
PDDocVersion* majorP = new PDDocVersion();
PDDocVersion* minorP = new PDDocVersion();
PDDocGetVersion(doc, majorP, minorP);
PDDocSaveParams saveParams = (PDDocSaveParams)malloc(sizeof(PDDocSaveParamsRec));
saveParams->size = sizeof(PDDocSaveParamsRec);
saveParams->major = *majorP;
saveParams->minor = *minorP;
saveParams->mon = NULL;
saveParams->monClientData = NULL;
saveParams->cancelProc = NULL;
saveParams->cancelProcClientData = NULL;
saveParams->preSaveProc = NULL;
saveParams->preSaveProcClientData = NULL;
saveParams->offsetProc = NULL;
saveParams->offsetProcClientData = NULL;
saveParams->preWriteProc = NULL;
saveParams->preWriteProcClientData = NULL;
saveParams->saveFlags = PDSaveFull | PDSaveCopy | PDSaveCollectGarbage;
saveParams->fileSys = fileSys;
saveParams->newPath = pathName;
PDDocSaveWithParams(doc, saveParams);
ASTFilePos newFileSize;
newFileSize = GetFileSize(saveFilePath);
ASFileSysReleasePath(fileSys, pathName);
free(saveParams);
free(majorP);
free(minorP);