Skip to content

Commit c95ede5

Browse files
committed
PDFBOX-5660: simplify code, as suggested by Valery Bokov; closes #214
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1927841 13f79535-47bb-0310-9956-ffa450edef68
1 parent 09faf66 commit c95ede5

File tree

1 file changed

+10
-14
lines changed
  • pdfbox/src/main/java/org/apache/pdfbox/pdmodel

1 file changed

+10
-14
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,19 @@ public RandomAccessRead getContentsForStreamParsing() throws IOException
234234
{
235235
// return a stream based reader if there is just one stream
236236
COSStream contentStream = page.getCOSStream(COSName.CONTENTS);
237-
if (contentStream != null)
237+
if (contentStream != null && COSName.FLATE_DECODE.equals(contentStream.getFilters()))
238238
{
239-
COSBase filter = contentStream.getFilters();
240239
// for now only streams using a flate filter are supported
241-
if (filter instanceof COSName && ((COSName) filter).equals(COSName.FLATE_DECODE))
240+
try
242241
{
243-
try
244-
{
245-
FlateFilterDecoderStream decoderStream = new FlateFilterDecoderStream(
246-
contentStream.createRawInputStream());
247-
return new NonSeekableRandomAccessReadInputStream(decoderStream);
248-
}
249-
catch (IOException exception)
250-
{
251-
LOG.warn("skipped malformed content stream");
252-
return new RandomAccessReadBuffer(DELIMITER);
253-
}
242+
FlateFilterDecoderStream decoderStream = new FlateFilterDecoderStream(
243+
contentStream.createRawInputStream());
244+
return new NonSeekableRandomAccessReadInputStream(decoderStream);
245+
}
246+
catch (IOException exception)
247+
{
248+
LOG.warn("skipped malformed content stream");
249+
return new RandomAccessReadBuffer(DELIMITER);
254250
}
255251
}
256252
return getContentsForRandomAccess();

0 commit comments

Comments
 (0)