[ 
https://issues.apache.org/jira/browse/PDFBOX-5099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17281799#comment-17281799
 ] 

Michael Klink commented on PDFBOX-5099:
---------------------------------------

{quote}I guess it is an illegal Date value .{quote}
Yes, it is. According to the specification:

{panel:title=ISO 32000-2:2017, section 7.9.4 Dates}
date shall be a text string containing no whitespace, of the form:

(D:YYYYMMDDHHmmSSOHH'mm)

...

The prefix D: shall be present, the year field (YYYY) shall be present and all 
other fields may be present but only if all of their preceding fields are also 
present. The APOSTROPHE following the hour offset field (HH) shall only be 
present if the HH field is present. The minute offset field (mm) shall only be 
present if the APOSTROPHE following the hour offset field (HH) is present.
{panel}

So {{(D: )}} is wrong in two ways, the year YYYY is missing and there is an 
invalid space.

> 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
>            Priority: Minor
>
> 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).
> Looking inside the PDF structure this is the Info:
> {quote}7 0 obj
>  <<
>  /CreationDate (D: )
>  /Creator (Samsung Electronics)
>  /Producer (CloudConvert)
>  /ModDate (D:20210209103114Z)
>  /Keywords (urn:uuid:313707-D7BA577B-6584-AC90-7235-4BDFD4C6CCB8)
> {quote}
>  
> I guess it is an illegal Date value .
>  
>  
>  



--
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