SourceForge has been redesigned. Learn more.

Why do I get this error?

  • NaZAf

    NaZAf - 2008-05-01

    I am just opening a PDF, type a text and save to a new file!

    With some files it work but with others I get this error:

    "Unhandled Exception: System.FormatException: The DateTime represented by the str
    ing is not supported in calendar System.Globalization.GregorianCalendar.
       at it.stefanochizzolini.clown.objects.PdfIndirectObject.get_DataObject()
       at it.stefanochizzolini.clown.objects.PdfIndirectObject.WriteTo(IOutputStream
       at it.stefanochizzolini.clown.tokens.Writer.WriteStandard()
       at it.stefanochizzolini.clown.files.File.WriteTo(IOutputStream stream, Serial
    izationModeEnum mode)
       at it.stefanochizzolini.clown.files.File.WriteTo(String path, SerializationMo
    deEnum mode)
       at main(String[] args) in ..."

    Any ideas ?

    • Stefano Chizzolini


      could you please send me (if it doesn't hurt your privacy) one of such PDF files along with the code you used to produce this error so that I'm able to reproduce it?
      See my personal info page [1] to get my email address.

      Thank you


    • NaZAf

      NaZAf - 2008-05-01

      OK. Of course!

      my code:
      my PDF:

      NOTE: This occurs when using STANDARD serialization only, with INCREMENTAL, it works 100% fine.

    • Stefano Chizzolini

      Your error is caused by parsing the following entry within the Information dictionary of your PDF file:

      /CreationDate (D:00000101000000Z)

      which reads as "January 1, 0000, midnight, UTC".

      The problem is that it collides with an implementation limitation of the DateTime structure [1] in the context of the GregorianCalendar class [2] of the .NET Framework which states that date representation is limited to "values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.)": to say that January 1, 0000 (your date) is OUT of range!

      If you get a try to the Java implementation of PDF Clown, you'll find that it deals successfully with your PDF file instead.

      I couldn't find implementation notes about dates in the PDF spec, but opening your PDF file with Adobe Reader 8 I curiously got "01/01/1900 12:00:00 AM" as the representation of your date in the "Document properties" window...

      It's quite evident that your date is semantically wrong, but I'll consider dealing with such an exceptional case (out-of-range dates) in the next releases, to let PDF Clown's execution survive.



    • NaZAf

      NaZAf - 2008-05-09

      Thanks Stefano,
      I located the source code in .NET and handled the exception manually since PDF documents might have incorrect creation date. Anyway, I send you a link to the hotfix - you can consider this for your future release.

      [ PdfDate.cs ] -

      Also, It would be great if you can improve PDF Clown documentation. It is not friendly at all; I just learnt from your examples.

      Best Regards,

    • Stefano Chizzolini

      I agree with you, Nadeem: its documentation is currently way too sketchy... I'll revise it for the next release.
      In the meantime, users' feedback will be invaluable to focus their actual informative needs, so I warmly ask anybody interested to brainstorm ideas about hot topics regarding the use of PDF Clown.



Log in to post a comment.