You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Stefan Geelen (Jira)" <ji...@apache.org> on 2021/02/09 12:41:00 UTC

[jira] [Created] (PDFBOX-5099) PDDocumentInformation java.lang.StringIndexOutOfBoundsException: String index out of range: 2

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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org