@@ -40,7 +40,14 @@ source product.
40
40
For more information, please contact iText Software Corp. at this
41
41
42
42
*/
43
+ using System ;
44
+ using System . Collections . Generic ;
43
45
using iText . IO . Source ;
46
+ using iText . Kernel . Geom ;
47
+ using iText . Kernel . Pdf . Canvas . Parser ;
48
+ using iText . Kernel . Pdf . Canvas . Parser . Data ;
49
+ using iText . Kernel . Pdf . Canvas . Parser . Listener ;
50
+ using iText . Kernel . Pdf . Colorspace ;
44
51
using iText . Test ;
45
52
46
53
namespace iText . Kernel . Pdf {
@@ -197,5 +204,36 @@ public virtual void TestIndexOf2() {
197
204
NUnit . Framework . Assert . AreEqual ( i , array . IndexOf ( array2 . Get ( i ) ) ) ;
198
205
}
199
206
}
207
+
208
+ [ NUnit . Framework . Test ]
209
+ public virtual void PdfUncoloredPatternColorSize1Test ( ) {
210
+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new ByteArrayOutputStream ( ) ) ) ;
211
+ String contentColorSpace = "/Cs1 cs\n " ;
212
+ PdfDictionary pageDictionary = ( PdfDictionary ) new PdfDictionary ( ) . MakeIndirect ( pdfDocument ) ;
213
+ PdfStream contentStream = new PdfStream ( contentColorSpace . GetBytes ( ) ) ;
214
+ pageDictionary . Put ( PdfName . Contents , contentStream ) ;
215
+ PdfPage page = pdfDocument . AddNewPage ( ) ;
216
+ page . GetPdfObject ( ) . Put ( PdfName . Contents , contentStream ) ;
217
+ PdfArray pdfArray = new PdfArray ( ) ;
218
+ pdfArray . Add ( PdfName . Pattern ) ;
219
+ PdfColorSpace space = PdfColorSpace . MakeColorSpace ( pdfArray ) ;
220
+ page . GetResources ( ) . AddColorSpace ( space ) ;
221
+ Rectangle rectangle = new Rectangle ( 50 , 50 , 1000 , 1000 ) ;
222
+ page . SetMediaBox ( rectangle ) ;
223
+ PdfCanvasProcessor processor = new PdfCanvasProcessor ( new PdfArrayTest . NoOpListener ( ) ) ;
224
+ processor . ProcessPageContent ( page ) ;
225
+ // Check if we reach the end of the test without failings together with verifying expected color space instance
226
+ NUnit . Framework . Assert . IsTrue ( processor . GetGraphicsState ( ) . GetFillColor ( ) . GetColorSpace ( ) is PdfSpecialCs . Pattern
227
+ ) ;
228
+ }
229
+
230
+ private class NoOpListener : IEventListener {
231
+ public virtual void EventOccurred ( IEventData data , EventType type ) {
232
+ }
233
+
234
+ public virtual ICollection < EventType > GetSupportedEvents ( ) {
235
+ return null ;
236
+ }
237
+ }
200
238
}
201
239
}
0 commit comments