3535using PdfSharpCore . Exceptions ;
3636using PdfSharpCore . Internal ;
3737using PdfSharpCore . Pdf . Advanced ;
38- using PdfSharpCore . Pdf . Internal ;
3938using PdfSharpCore . Pdf . IO . enums ;
4039
4140namespace PdfSharpCore . Pdf . IO
4241{
4342 /*
44- Direct and indireckt objects
43+ Direct and indirect objects
4544
4645 * If a simple object (boolean, integer, number, date, string, rectangle etc.) is referenced indirect,
4746 the parser reads this objects immediatly and consumes the indirection.
@@ -52,7 +51,7 @@ is returned.
5251 * If a composite object is a direct object, no PdfReference is created and the object is
5352 parsed immediatly.
5453
55- * A refernece to a non existing object is specified as legal, therefore null is returned.
54+ * A reference to a non existing object is specified as legal, therefore null is returned.
5655 */
5756
5857 /// <summary>
@@ -1256,16 +1255,7 @@ private PdfTrailer ReadXRefStream(PdfCrossReferenceTable xrefTable)
12561255 Debug . Assert ( xrefStream . Stream != null ) ;
12571256 //string sValue = new RawEncoding().GetString(xrefStream.Stream.UnfilteredValue,);
12581257 //sValue.GetType();
1259- byte [ ] bytesRaw = xrefStream . Stream . UnfilteredValue ;
1260- byte [ ] bytes = bytesRaw ;
1261-
1262- // HACK: Should be done in UnfilteredValue.
1263- if ( xrefStream . Stream . HasDecodeParams )
1264- {
1265- int predictor = xrefStream . Stream . DecodePredictor ;
1266- int columns = xrefStream . Stream . DecodeColumns ;
1267- bytes = DecodeCrossReferenceStream ( bytesRaw , columns , predictor ) ;
1268- }
1258+ var bytes = xrefStream . Stream . UnfilteredValue ;
12691259
12701260#if DEBUG_
12711261 for ( int idx = 0 ; idx < bytes . Length ; idx ++ )
@@ -1351,7 +1341,7 @@ private PdfTrailer ReadXRefStream(PdfCrossReferenceTable xrefTable)
13511341 //// (PDF Reference Implementation Notes 15).
13521342
13531343 int position = ( int ) item . Field2 ;
1354- objectID = ReadObjectNumber ( position ) ;
1344+ objectID = ReadObjectNumber ( position ) ;
13551345#if DEBUG
13561346 if ( objectID . ObjectNumber == 1074 )
13571347 GetType ( ) ;
@@ -1364,7 +1354,7 @@ private PdfTrailer ReadXRefStream(PdfCrossReferenceTable xrefTable)
13641354#if DEBUG
13651355 GetType ( ) ;
13661356#endif
1367- // Add iref for all uncrompressed objects.
1357+ // Add iref for all uncompressed objects.
13681358 xrefTable . Add ( new PdfReference ( objectID , position ) ) ;
13691359
13701360 }
@@ -1771,44 +1761,6 @@ private class ParserState
17711761 public Symbol Symbol ;
17721762 }
17731763
1774- private byte [ ] DecodeCrossReferenceStream ( byte [ ] bytes , int columns , int predictor )
1775- {
1776- int size = bytes . Length ;
1777- if ( predictor < 10 || predictor > 15 )
1778- throw new ArgumentException ( "Invalid predictor." , "predictor" ) ;
1779-
1780- int rowSizeRaw = columns + 1 ;
1781-
1782- if ( size % rowSizeRaw != 0 )
1783- throw new ArgumentException ( "Columns and size of array do not match." ) ;
1784-
1785- int rows = size / rowSizeRaw ;
1786-
1787- byte [ ] result = new byte [ rows * columns ] ;
1788- #if DEBUG
1789- for ( int i = 0 ; i < result . Length ; ++ i )
1790- result [ i ] = 88 ;
1791- #endif
1792-
1793- for ( int row = 0 ; row < rows ; ++ row )
1794- {
1795- if ( bytes [ row * rowSizeRaw ] != 2 )
1796- throw new ArgumentException ( "Invalid predictor in array." ) ;
1797-
1798- for ( int col = 0 ; col < columns ; ++ col )
1799- {
1800- // Copy data for first row.
1801- if ( row == 0 )
1802- result [ row * columns + col ] = bytes [ row * rowSizeRaw + col + 1 ] ;
1803- else
1804- {
1805- // For other rows, add previous row.
1806- result [ row * columns + col ] = ( byte ) ( result [ row * columns - columns + col ] + bytes [ row * rowSizeRaw + col + 1 ] ) ;
1807- }
1808- }
1809- }
1810- return result ;
1811- }
18121764
18131765 private readonly PdfDocument _document ;
18141766 private readonly Lexer _lexer ;
0 commit comments