You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Martijn Brinkers (JIRA)" <ji...@apache.org> on 2010/11/20 00:46:13 UTC
[jira] Created: (PDFBOX-897) NullPointerException
PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
----------------------------------------------------------------------------------------------
Key: PDFBOX-897
URL: https://issues.apache.org/jira/browse/PDFBOX-897
Project: PDFBox
Issue Type: Bug
Components: Parsing
Affects Versions: 1.3.1
Reporter: Martijn Brinkers
Attachments: PDFBOX-897.patch
A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in
PDFFont#getEncodingFromFont line:
[snip]
encoding.addCharacterEncoding(index, name.replace("/", ""));
[snip]
encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.
I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:
Acrobat Distiller 7.0 (Windows)
PScript5.dll Version 5.2.2
PDF-1.6
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-897) NullPointerException
PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934067#action_12934067 ]
Adam Nichols commented on PDFBOX-897:
-------------------------------------
I'm looking at PDFont and the only place I see:
encoding.addCharacterEncoding(index, name.replace("/", ""));
is on line 832, which is within this block:
else if (line.startsWith("dup")) {
Since your line doesn't begin with dup, I'm not sure why this line would ever be executed, nor how your patch would fix anything. Are you using the latest version of PDFBox? Maybe someone changed this between the version you are using and the one I'm looking at. I'm looking at the latest code from SVN.
> NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
> ----------------------------------------------------------------------------------------------
>
> Key: PDFBOX-897
> URL: https://issues.apache.org/jira/browse/PDFBOX-897
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 1.3.1
> Reporter: Martijn Brinkers
> Attachments: PDFBOX-897.patch
>
>
> A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in
> PDFFont#getEncodingFromFont line:
> [snip]
> encoding.addCharacterEncoding(index, name.replace("/", ""));
> [snip]
> encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.
> I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:
> Acrobat Distiller 7.0 (Windows)
> PScript5.dll Version 5.2.2
> PDF-1.6
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (PDFBOX-897) NullPointerException
PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
Posted by "Martijn Brinkers (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martijn Brinkers updated PDFBOX-897:
------------------------------------
Attachment: PDFBOX-897.patch
Patch for bug 897 added
> NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
> ----------------------------------------------------------------------------------------------
>
> Key: PDFBOX-897
> URL: https://issues.apache.org/jira/browse/PDFBOX-897
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 1.3.1
> Reporter: Martijn Brinkers
> Attachments: PDFBOX-897.patch
>
>
> A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in
> PDFFont#getEncodingFromFont line:
> [snip]
> encoding.addCharacterEncoding(index, name.replace("/", ""));
> [snip]
> encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.
> I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:
> Acrobat Distiller 7.0 (Windows)
> PScript5.dll Version 5.2.2
> PDF-1.6
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (PDFBOX-897) NullPointerException
PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Adam Nichols resolved PDFBOX-897.
---------------------------------
Resolution: Fixed
Fix Version/s: 1.4.0
Assignee: Adam Nichols
Thanks for the extra info, now I understand how it can be null. I committed your patch and added an extra protection to avoid a NPE in case there's any exceptional case (i.e. a non-conforming, and/or corrupt PDF). I also added some logging info so if there so if we ever come across one of these exceptional cases, it will at least be logged so users can track it down. Committed in revision 1037891.
> NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
> ----------------------------------------------------------------------------------------------
>
> Key: PDFBOX-897
> URL: https://issues.apache.org/jira/browse/PDFBOX-897
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 1.3.1
> Reporter: Martijn Brinkers
> Assignee: Adam Nichols
> Fix For: 1.4.0
>
> Attachments: PDFBOX-897.patch
>
>
> A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in
> PDFFont#getEncodingFromFont line:
> [snip]
> encoding.addCharacterEncoding(index, name.replace("/", ""));
> [snip]
> encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.
> I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:
> Acrobat Distiller 7.0 (Windows)
> PScript5.dll Version 5.2.2
> PDF-1.6
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-897) NullPointerException
PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
Posted by "Martijn Brinkers (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934110#action_12934110 ]
Martijn Brinkers commented on PDFBOX-897:
-----------------------------------------
What happens is this:
encoding is null until encoding is initialized when /Encoding ... array is found. However if the /Encoding...array line is not matched, which happens for example with this line "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for" because the line does not end with array, encoding remains null. When the line that starts with "dup" is found, a NullPointerException will be thrown because encoding is null. The patch makes sure that the encoding is detected even when "array" is somewhere in the middle
> NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null
> ----------------------------------------------------------------------------------------------
>
> Key: PDFBOX-897
> URL: https://issues.apache.org/jira/browse/PDFBOX-897
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 1.3.1
> Reporter: Martijn Brinkers
> Attachments: PDFBOX-897.patch
>
>
> A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in
> PDFFont#getEncodingFromFont line:
> [snip]
> encoding.addCharacterEncoding(index, name.replace("/", ""));
> [snip]
> encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255 {1 index exch /.notdef put} for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.
> I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:
> Acrobat Distiller 7.0 (Windows)
> PScript5.dll Version 5.2.2
> PDF-1.6
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.