Esempio n. 1
0
 /// <summary>
 /// Creates the xref table using the byte offsets in the array.
 /// </summary>
 /// <returns></returns>
 internal byte[] CreateXrefTable(long fileOffset, out int size)
 {
     //Store the Offset of the Xref table for startxRef
     string table = null;
     try
     {
         ObjectList objList = new ObjectList(0, fileOffset);
         pa.offsets.Add(objList);
         pa.offsets.Sort();
         numTableEntries = (int)pa.offsets.Count;
         table = string.Format("\r\nxref {0} {1}\r\n0000000000 65535 f\r\n", 0, numTableEntries);
         for (int entries = 1; entries < numTableEntries; entries++)
         {
             ObjectList obj = pa.offsets[entries];
             table += obj.offset.ToString().PadLeft(10, '0');
             table += " 00000 n\r\n";
         }
     }
     catch (Exception e)
     {
         Exception error = new Exception(e.Message + " In Utility.CreateXrefTable()");
         throw error;
     }
     return GetUTF8Bytes(table, out size);
 }
Esempio n. 2
0
		/// <summary>
		/// Gets the image entries to be written to the file
		/// </summary>
		/// <returns></returns>
		internal byte[] GetImageDict(long filePos,out int size)
		{
			MemoryStream ms=new MemoryStream();
			int s;
			byte[] ba;
			foreach (PdfImageEntry ie in images.Values)
			{
				ObjectList objList=new ObjectList(ie.objectNum,filePos);
				ba = PdfUtility.GetUTF8Bytes(ie.imgDict, out s);
				ms.Write(ba, 0, ba.Length);
				filePos += s;

				ms.Write(ie.ba, 0, ie.ba.Length);		// write out the image
				filePos += ie.ba.Length;

				ba = PdfUtility.GetUTF8Bytes("endstream\r\nendobj\r\n", out s);
				ms.Write(ba, 0, ba.Length);
				filePos += s;
				ie.xref.offsets.Add(objList);
			}
			
			ba = ms.ToArray();
			size = ba.Length;
			return ba;
		}
Esempio n. 3
0
		/// <summary>
		/// Convert the unicode string 16 bits to unicode bytes. 
		/// This is written to the file to create Pdf 
		/// </summary>
		/// <returns></returns>
		internal byte[] GetUTF8Bytes(string str,long filePos,out int size)
		{
			ObjectList objList=new ObjectList(objectNum,filePos);
			byte []abuf;

            byte[] ubuf = Encoding.Unicode.GetBytes(str);
			Encoding enc = Encoding.GetEncoding(1252);
			abuf = Encoding.Convert(Encoding.Unicode, enc, ubuf);
			size=abuf.Length;
			xref.offsets.Add(objList);

            return abuf;
		}