Skip to main content
When you export a document to PDF or XPS format, you may encounter some specific errors:
  • FREN_E_INVALID_CREATION_DATE_FORMAT;
  • FREN_E_INVALID_MODIFICATION_DATE_FORMAT.
They appear if the creation or modification date specified in the document metadata does not comply with the PDF 2.0 standard. The correct date format is D:YYYYMMDDHHmmSSOHH’mm, where YYYY — the year, MM — the month, DD — the date, HHmmSS — the time, OHH’mm — the absolute value of the offset from Universal Time. To handle errors of this type, you may either change the date export settings or correct the date to fit the format. To change the date export settings:
  1. Get the DocumentContentInfoWritingParams subobject of the export parameters object for your output format:
  2. The WriteCreationDate and WriteModificationDate properties of the DocumentContentInfoWritingParams object specify which dates should be saved into the output document. In this case, you may use the WD_No value to disable date saving and the WD_Current value to use the current date.
  3. Restart the document export using, for example, the Export method of the FRDocument object, passing the parameters object you have just set up as the last input parameter.
To correct the date:
  1. Access the DocumentСontentInfo object using the DocumentContentInfo property of the FRDocument object.
  2. Change the date in the CreationDate or ModificationDate property of the DocumentСontentInfo object.
  3. Restart the document export with the Export method of the FRDocument object.

Samples

The code samples provided in this topic are Windows -specific.
// Set the export parameters object of the creation and modification dates
FREngine::IPDFExportParamsPtr pdfExportParams = Engine->CreatePDFExportParams();
pdfExportParams->PDFFeatures->MetaDataWritingParams->put_WriteCreationDate ( FREngine::WD_DocumentContentInfo );
pdfExportParams->PDFFeatures->MetaDataWritingParams->put_WriteModificationDate ( FREngine::WD_DocumentContentInfo );
 
// Correct the creation/modification date and export the document again
const int numberOfExportAttempts = 3;
for (int i = 0; i < numberOfExportAttempts; i++)
{
  try
  {
     frDocument->Export( pdfExportPath, FREngine::FEF_PDF, pdfExportParams );
  }
  catch (_com_error & e)
  {
     if (e.Error() == (int) FREngine::FREN_E_INVALID_CREATION_DATE_FORMAT) {
         frDocument->DocumentContentInfo->put_CreationDate( L"D:20181011234506Z" );
     }
     else if (e.Error() == (int) FREngine::FREN_E_INVALID_MODIFICATION_DATE_FORMAT) {
         pdfExportParams->PDFFeatures->MetaDataWritingParams->put_WriteModificationDate ( FREngine::WD_Current );
     }
     else
     {
           // Restore the original unhandled exception and pass it on
           throw;
     }
  }
}
// Set the export parameters of the creation and modification dates
FREngine.PDFExportParams pdfExportParams = engineLoader.Engine.CreatePDFExportParams();
pdfExportParams.PDFFeatures.MetaDataWritingParams.WriteCreationDate = FREngine.WriteDateEnum.WD_DocumentContentInfo;
pdfExportParams.PDFFeatures.MetaDataWritingParams.WriteModificationDate = FREngine.WriteDateEnum.WD_DocumentContentInfo;
 
// Handle two types of the export errors, so there should be no more than 3 export attempts
const int numberOfExportAttempts = 3;
for (int i = 0; i < numberOfExportAttempts; ++i)
{
    try
    {
       document.Export( "D:\\Demo.pdf", FREngine.FileExportFormatEnum.FEF_PDF, pdfExportParams );
       break;
    }
    catch (COMException error)
    {
       if (error.ErrorCode == (int)FREngine.ErrorCodes.FREN_E_INVALID_CREATION_DATE_FORMAT)
       {
           // Correct the creation date
           document.DocumentContentInfo.CreationDate = "D:20181011234506Z";
       }
       else if (error.ErrorCode == (int)FREngine.ErrorCodes.FREN_E_INVALID_MODIFICATION_DATE_FORMAT)
       {
           // Change the export parameters of the modification date
           pdfExportParams.PDFFeatures.MetaDataWritingParams.WriteModificationDate = FREngine.WriteDateEnum.WD_Current;
       }
       else
       {
           // Restore the original unhandled exception and pass it on
           throw;
       }
    }
}

See also

DocumentСontentInfo Standard Return Codes Tuning Export Parameters Error Handling