You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Gerstinger (Jira)" <ji...@apache.org> on 2020/12/07 22:17:00 UTC
[jira] [Created] (PDFBOX-5036) IllegalArgumentException in
PDImageXObject.getImage()
Andreas Gerstinger created PDFBOX-5036:
------------------------------------------
Summary: IllegalArgumentException in PDImageXObject.getImage()
Key: PDFBOX-5036
URL: https://issues.apache.org/jira/browse/PDFBOX-5036
Project: PDFBox
Issue Type: Bug
Affects Versions: 2.0.21
Environment: JDK11
Reporter: Andreas Gerstinger
Attachments: Phaeton.pdf
An IllegalArgumentException (runtime exception) is thrown in the getImage() method of PDImageXObject. The method declares to throw IOException, which is fine, but I do not know how to prevent it to throw the IllegalArgumentException. Only happens for some PDFs, one that is affected is attached.
Here is the code that provokes the exception:
{{{color:#000080}public static void {color}main(String[] args) {}}
{{ {color:#000080}try {color}{}}
{{ PDDocument document = PDDocument.load({color:#000080}new {color}File({color:#008000}"Phaeton.pdf"{color}));}}
{{ PDResources pdRes = document.getPages().get({color:#0000ff}0{color}).getResources();}}
{{ {color:#000080}for {color}(COSName name : pdRes.getXObjectNames()) {}}
{{ PDXObject o = pdRes.getXObject(name);}}
{{ {color:#000080}if {color}(o {color:#000080}instanceof {color}PDImageXObject) {}}
{{ PDImageXObject img = (PDImageXObject) o;}}
{{ img.getImage(); {color:#808080}// This throws an java.lang.IllegalArgumentException (runtime exception) - bug in PDFBOX???
{color} }}}
{{ }}}
{{ } {color:#000080}catch{color}(IOException e) {}}
{{ System.{color:#660e7a}out{color}.println({color:#008000}"IOException thrown..."{color});}}{{ }}}
{{}}}
--
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