> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handling Errors During PDF/XPS Export

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](/fine-reader/engine/api-reference/parameter-objects/export-parameters/documentcontentinfowritingparams) subobject of the export parameters object for your output format:
   * For PDF export, you can use the [PDFFeatures](/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfexportparams#pdffeatures) property of the [PDFExportParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfexportparams) object to access the [PDFExportFeatures](/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfexportfeatures) object, then use its [MetaDataWritingParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfexportfeatures#metadatawritingparams) property to get the [DocumentContentInfoWritingParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/documentcontentinfowritingparams) object.
   * For XPS export, use the [MetaDataWritingParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/xpsexportparams#metadatawritingparams) property of the [XPSExportParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/xpsexportparams) object.
2. The [WriteCreationDate](/fine-reader/engine/api-reference/parameter-objects/export-parameters/documentcontentinfowritingparams#writecreationdate) and [WriteModificationDate](/fine-reader/engine/api-reference/parameter-objects/export-parameters/documentcontentinfowritingparams#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](/fine-reader/engine/api-reference/document-related-objects/frdocument/export-method) method of the [FRDocument](/fine-reader/engine/api-reference/document-related-objects/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](/fine-reader/engine/api-reference/document-related-objects/documentcontentinfo) object using the [DocumentContentInfo](/fine-reader/engine/api-reference/document-related-objects/frdocument#documentcontentinfo) property of the [FRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument) object.
2. Change the date in the [CreationDate](/fine-reader/engine/api-reference/document-related-objects/documentcontentinfo#creation_date) or [ModificationDate](/fine-reader/engine/api-reference/document-related-objects/documentcontentinfo#modification_date) property of the DocumentСontentInfo object.
3. Restart the document export with the [Export](/fine-reader/engine/api-reference/document-related-objects/frdocument/export-method) method of the FRDocument object.

## Samples

<Note>
  The code samples provided in this topic are Windows -specific.
</Note>

<Accordion title="C++ code">
  ```cpp theme={null}
  // 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;
       }
    }
  }
  ```
</Accordion>

<Accordion title="C# code">
  ```csharp theme={null}
  // 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;
         }
      }
  }
  ```
</Accordion>

## See also

[DocumentСontentInfo](/fine-reader/engine/api-reference/document-related-objects/frdocument#documentcontentinfo)

[Standard Return Codes](/fine-reader/engine/api-reference/return-codes)

[Tuning Export Parameters](/fine-reader/engine/guided-tour/advanced-techniques/tuning-export-parameters)

[Error Handling](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/error-handling)
