Stefan Geelen created PDFBOX-5099:
-------------------------------------

             Summary: PDDocumentInformation 
java.lang.StringIndexOutOfBoundsException: String index out of range: 2
                 Key: PDFBOX-5099
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5099
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.21
         Environment: PDFBox 2.0.21 Java
            Reporter: Stefan Geelen


I have a PDF without CreateDate

Following 
{quote}PDDocumentInformation docinfo = pdDoc.getDocumentInformation();

docinfo.getCreationDate();
{quote}
throws
{quote}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)
{quote}
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.

a 
{quote}docinfo.hasCreationDate();
{quote}
would also be handy (same for other properties).

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to