Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5099

PDDocumentInformation java.lang.StringIndexOutOfBoundsException: String index out of range: 2

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 2.0.21
    • None
    • None
    • None
    • PDFBox 2.0.21 Java

    Description

      I have a PDF without CreateDate

      Following 

      PDDocumentInformation docinfo = pdDoc.getDocumentInformation();

      docinfo.getCreationDate();

      throws

      java.lang.StringIndexOutOfBoundsException: String index out of range: 2java.lang.StringIndexOutOfBoundsException: String index out of range: 2 at java.lang.String.charAt(String.java:658) at org.apache.pdfbox.util.DateConverter.parseDate(DateConverter.java:656) at org.apache.pdfbox.util.DateConverter.toCalendar(DateConverter.java:724) at org.apache.pdfbox.util.DateConverter.toCalendar(DateConverter.java:702) at org.apache.pdfbox.cos.COSDictionary.getDate(COSDictionary.java:861) at org.apache.pdfbox.pdmodel.PDDocumentInformation.getCreationDate(PDDocumentInformation.java:212)

      Better should be to return null in case no createdate exists (same with getModificationDate I assume - not tested).

      Currently there is no other way tha putting this in a  try catch to omit this error.

      docinfo.hasCreationDate();

      would also be handy (same for other properties).

      Looking inside the PDF structure this is the Info:

      7 0 obj
      <<
      /CreationDate (D: )
      /Creator (Samsung Electronics)
      /Producer (CloudConvert)
      /ModDate (D:20210209103114Z)
      /Keywords (urn:uuid:313707-D7BA577B-6584-AC90-7235-4BDFD4C6CCB8)

       

      I guess it is an illegal Date value .

       

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              SGE00 Stefan Geelen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: