public void Start() { // Create the anchor for all pdf objects CompressionConfig cc = RdlEngineConfig.GetCompression(); //Set initialize dmpcontent dmpContent = new StringBuilder(""); }
static void GetCompression(XmlNode xNode) { // loop thru looking to process all the datasource elements string cm = null; string cn = null; string fn = null; bool bEnable = true; foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "CodeModule": if (xNodeLoop.InnerText.Length > 0) { cm = xNodeLoop.InnerText; } break; case "ClassName": if (xNodeLoop.InnerText.Length > 0) { cn = xNodeLoop.InnerText; } break; case "Finish": if (xNodeLoop.InnerText.Length > 0) { fn = xNodeLoop.InnerText; } break; case "Enable": if (xNodeLoop.InnerText.ToLower() == "false") { bEnable = false; } break; } } if (bEnable) { _Compression = new CompressionConfig(cm, cn, fn); } else { _Compression = null; } }
public void Start() { // Create the anchor for all pdf objects CompressionConfig cc = RdlEngineConfig.GetCompression(); anchor = new PdfAnchor(cc != null); //Create a PdfCatalog string lang; if (r.ReportDefinition.Language != null) { lang = r.ReportDefinition.Language.EvaluateString(this.r, null); } else { lang = null; } catalog = new PdfCatalog(anchor, lang); //Create a Page Tree Dictionary pageTree = new PdfPageTree(anchor); //Create a Font Dictionary fonts = new PdfFonts(anchor); //Create a Pattern Dictionary patterns = new PdfPattern(anchor); //Create an Image Dictionary images = new PdfImages(anchor); //Create an Outline Dictionary outline = new PdfOutline(anchor); //Create the info Dictionary info = new PdfInfo(anchor); //Set the info Dictionary. info.SetInfo(r.Name, r.Author, r.Description, ""); // title, author, subject, company //Create a utility object pdfUtility = new PdfUtility(anchor); //write out the header int size = 0; tw.Write(pdfUtility.GetHeader("1.5", out size), 0, size); filesize = size; }
static void GetCompression(XmlNode xNode) { // loop thru looking to process all the datasource elements string cm = null; string cn = null; string fn = null; bool bEnable = true; foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "CodeModule": if (xNodeLoop.InnerText.Length > 0) cm = xNodeLoop.InnerText; break; case "ClassName": if (xNodeLoop.InnerText.Length > 0) cn = xNodeLoop.InnerText; break; case "Finish": if (xNodeLoop.InnerText.Length > 0) fn = xNodeLoop.InnerText; break; case "Enable": if (xNodeLoop.InnerText.ToLower() == "false") bEnable = false; break; } } if (bEnable) _Compression = new CompressionConfig(cm, cn, fn); else _Compression = null; }
/// <summary> /// Content object /// </summary> /// <summary> /// Get the Content Dictionary /// </summary> public byte[] GetContentDict(long filePos, out int size) { // When no compression if (!CanCompress) { content = string.Format("\r\n{0} 0 obj<</Length {1}>>stream\r{2}\rendstream\rendobj\r", this.objectNum, contentStream.Length, contentStream); return(GetUTF8Bytes(content, filePos, out size)); } // Try to use compression; could still fail in which case fall back to uncompressed Stream strm = null; MemoryStream cs = null; try { CompressionConfig cc = RdlEngineConfig.GetCompression(); cs = new MemoryStream(); // this will contain the content stream if (cc != null) { strm = cc.GetStream(cs); } if (strm == null) { // can't compress string cs.Close(); content = string.Format("\r\n{0} 0 obj<</Length {1}>>stream\r{2}\rendstream\rendobj\r", this.objectNum, contentStream.Length, contentStream); return(GetUTF8Bytes(content, filePos, out size)); } // Compress the contents int cssize; byte[] ca = PdfUtility.GetUTF8Bytes(contentStream, out cssize); strm.Write(ca, 0, cssize); strm.Flush(); cc.CallStreamFinish(strm); // Now output the PDF command MemoryStream ms = new MemoryStream(); int s; byte[] ba; // get the compressed data; we need the lenght now byte[] cmpData = cc.GetArray(cs); // write the beginning portion of the PDF object string ws = string.Format("\r\n{0} 0 obj<< /Filter /FlateDecode /Length {1}>>stream\r", this.objectNum, cmpData.Length); ba = GetUTF8Bytes(ws, filePos, out s); // this will also register the object ms.Write(ba, 0, ba.Length); filePos += s; // write the Compressed data ms.Write(cmpData, 0, cmpData.Length); filePos += ba.Length; // write the end portion of the PDF object ba = PdfUtility.GetUTF8Bytes("\rendstream\rendobj\r", out s); ms.Write(ba, 0, ba.Length); filePos += s; // now the final output array ba = ms.ToArray(); size = ba.Length; return(ba); } finally { if (strm != null) { strm.Close(); } } }