Blog

Friend's Note
SY0-101 and N10-003 are advanced exams that come after 642-812, if the student has not done 70-431 and in case he has, it comes after 350-030 since then 220-602 is exempted.
 
1:   using System;
2:   using System.IO;
3:  
4:   using iTextSharp.text;
5:   using iTextSharp.text.pdf;
6:  
7:   namespace iTextSharp.tutorial.Chap06
8:   {
9:       /// <summary>
10:       /// Raw Image data:
11:       /// Uptil now all examples used images that were stored on your harddisk or that were retrieved from some webserver, 
12:       /// but it is also possible to get an instance of an image using an array of bytes containing the image data
13:       /// </summary>
14:       public class Chap0609 
15:       {
16:       
17:           public Chap0609() 
18:           {
19:           
20:               Console.WriteLine("Chapter 6 example 9: bytes() / Raw Image");
21:           
22:               // step 1: creation of a document-object
23:               Document document new Document();
24:           
25:               try 
26:               {
27:               
28:                   // step 2:
29:                   // we create a writer that listens to the document
30:                   // and directs a PDF-stream to a file
31:               
32:                   PdfWriter.GetInstance(documentnew FileStream("Chap0609.pdf"FileMode.Create));
33:               
34:                   // step 3: we open the document
35:                   document.Open();
36:               
37:                   // step 4: we add content (example by Paulo Soares)
38:               
39:                   // creation a jpeg passed as an array of bytes to the Image
40:                   FileStream rf new FileStream("mykids.jpg"FileMode.OpenFileAccess.Read);
41:                   int size = (int)rf.Length;
42:                   byte[] imext new byte[size];
43:                   rf.Read(imext0size);
44:                   rf.Close();
45:                   Image img1 Image.GetInstance(imext);
46:                   img1.SetAbsolutePosition(50500);
47:                   document.Add(img1);
48:               
49:                   // creation of an image of 100 x 100 pixels (x 3 bytes for the Red, Green and Blue value)
50:                   byte[] data new byte[100*100*3];
51:                   for (int 0100; ++k
52:                   {
53:                       for (int 0300+= 3
54:                       {
55:                           data[300 j] = (byte)(255 Math.Sin(.5 Math.PI 300));
56:                           data[300 1] = (byte)(256 256 300);
57:                           data[300 2] = (byte)(255 Math.Cos(.5 Math.PI 100));
58:                       }
59:                   }
60:                   Image img2 Image.GetInstance(10010038data);
61:                   img2.SetAbsolutePosition(200200);
62:                   document.Add(img2);
63:               }
64:               catch(DocumentException de
65:               {
66:                   Console.Error.WriteLine(de.Message);
67:               }
68:               catch(IOException ioe
69:               {
70:                   Console.Error.WriteLine(ioe.Message);
71:               }
72:           
73:               // step 5: we close the document
74:               document.Close();
75:           }
76:       }
77:   }