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:
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.
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.
The code samples provided in this topic are Windows -specific.
C++ code
// Set the export parameters object of the creation and modification datesFREngine::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 againconst 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; } }}
C# code
// Set the export parameters of the creation and modification datesFREngine.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 attemptsconst 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; } }}