ODA PRC SDK audit functionality is not implemented yet. The audit public interface will be used for future implementation.
Auditing is a process of checking PRC contents for errors. If errors are found, error information is stored and can be retrieved for displaying or other purposes.
Audit of a .prc file can be implemented through the following steps:
::odrxDynamicLinker()->loadApp(OdPrcModuleName, false);
OdPrcAuditInfoImplPtr auditInfo = OdPrcAuditInfoImpl::createObject();
OdPrcFilePtr pDatabase = svcs.createDatabase();
pDatabase->readFile(prcName, auditInfo);
The prcName
parameter should contain the full path to the audited .prc
file. The auditInfo parameter contains a pointer to an audit information
class and notifies whether error checking should be performed while reading
the .prc file's content.
if (auditInfo->errorsFound())
{
const OdStringArray& info = auditInfo->errorInfo(); odPrintConsoleString(L"\nAudit reported %d error(s):\n", info.size()); for(OdUInt32 f=0; f(info.size(); ++f)
{
odPrintConsoleString(L"%ls\n", info[f].c_str());
}
}
else
{
odPrintConsoleString(L"\nAudit reported no errors.");
}
To provide correct handling of possible errors, the auditing source code can
use a try ... catch
section:
try
{
OdPrcAuditInfoImplPtr auditInfo = OdPrcAuditInfoImpl::createObject();
OdString prcName(argv[1]);
...
}
catch(OdError& e)
{
odPrintConsoleString(L"\n\nError: %ls", e.description().c_str());
nRes = -1;
}
catch(...)
{
odPrintConsoleString(L"\n\nUnexpected error.");
nRes = -1;
throw;
}
The OdPrcAudit sample application illustrates how to audit the PRC contents of a .pdf file.
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|