/// <summary> /// Procedimento que dispara a geração dos relatórios. /// </summary> private void GerarTermo() { Guid g; g = Guid.NewGuid(); this.ReportCadastro = new Root.Reports.Report(new Root.Reports.PdfFormatter()); this.FontDefin = new Root.Reports.FontDef(this.ReportCadastro, Root.Reports.FontDef.StandardFont.Helvetica); this.FontProp = new Root.Reports.FontProp(this.FontDefin, 7); this.NovaPagina(0); this.EscreverTermo(); //this.fileNamePDF = string.Format("TermoAdesao-{0}.pdf", this.GetIdCliente.ToString()); this.fileNamePDF = g.ToString(); if (this.SitemaOrigem == SistemaOrigem.Portal) { this.ReportCadastro.Save(string.Concat(this.GetEnderecoArquivoPortal, "\\", fileNamePDF)); } else { this.ReportCadastro.Save(string.Concat(this.GetEnderecoArquivoIntranet, "\\", fileNamePDF)); } }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a font properties data object for this formatter.</summary> /// <param name="fontProp"></param> internal override FontPropData fontPropData_CreateInstance(FontProp fontProp) { StringBuilder sb = new StringBuilder(50); sb.Append(fontProp.fontDef.sFontName); if (fontProp.bBold) { sb.Append(";B"); } if (fontProp.bItalic) { sb.Append(";I"); } String sKey = sb.ToString(); #if Framework2 FontProp fontProp_Reg; dict_FontProp.TryGetValue(sKey, out fontProp_Reg); #else FontProp fontProp_Reg = (FontProp)dict_FontProp[sKey]; #endif if (fontProp_Reg != null) // font registered //Debug.Assert(fontProp_Reg.fontPropData != null); { return(fontProp_Reg.fontPropData); } // Type1FontData afm = afm_Register(fontProp); PdfFontPropData pdfFontPropData = new PdfFontPropData(sKey, fontProp); dict_FontProp.Add(sKey, fontProp); return(pdfFontPropData); }
//------------------------------------------------------------------------------------------xx.02.2006 /// <summary>Registers the specified font properties for this page.</summary> /// <param name="fontProp">Font properties</param> /// <seealso cref="PdfPageData.ht_FontProp"/> /// <seealso cref="PdfFontPropData.pdfPageData_Registered"/> internal void RegisterFontProp(FontProp fontProp) { PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp.fontPropData; if (pdfFontPropData.pdfPageData_Registered != this) { ht_FontProp.Add(pdfFontPropData.sKey, fontProp); pdfFontPropData.pdfPageData_Registered = this; } }
//----------------------------------------------------------------------------------------------------x /// <summary>Gets the height of the font in 1/72 inches.</summary> /// <param name="fontProp">Font properties</param> /// <returns>Height of the font in 1/72 inches</returns> internal protected override Double rHeight(FontProp fontProp) { // Single fCapHeight = fontData.fCapHeight; // if (Single.IsNaN(fCapHeight)) { // fCapHeight = fontData.fFontBBox_ury - fontData.fFontBBox_lly; // } // Debug.Assert(!(Single.IsNaN(fCapHeight))); // return rSizeFactor(fontProp) * fCapHeight / 1000F; return(0); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new string object.</summary> /// <param name="fontProp">Font properties of the string object</param> /// <param name="sText">Text of the string object</param> public RepString(FontProp fontProp, String sText) { this.fontProp = fontProp.fontProp_Registered; this.sText = (sText == null) ? "" : sText; oRepObjX = fontProp.fontDef.report.formatter.oCreate_RepString(); if (fontProp.rAngle != 0) { RotateTransform(fontProp.rAngle); } }
//------------------------------------------------------------------------------------------07.02.2005 /// <summary>Creates a new font properties data object.</summary> internal FontPropData(FontProp fontProp) { FontDef.Style style; if (fontProp.bBold) { style = (fontProp.bItalic ? FontDef.Style.BoldItalic : FontDef.Style.Bold); } else { style = (fontProp.bItalic ? FontDef.Style.Italic : FontDef.Style.Standard); } fontData = fontProp.fontDef.aFontData[style]; }
protected void BreakByWord(ref RepString repString, out RepString repStringLeftover, double rWidth) { FontProp fp = repString.fontProp; StringBuilder sb = new StringBuilder(); StringBuilder sbLeftover = new StringBuilder(); double r_X = 0; foreach (string s in repString.sText.Split(null)) { if (sb.Length > 0) { r_X += fp.rWidth(" "); } r_X += fp.rWidth(s); if (r_X <= rWidth) { if (sb.Length > 0) { sb.Append(" "); } sb.Append(s); } else { if (sbLeftover.Length > 0) { sbLeftover.Append(" "); } sbLeftover.Append(s); } } if (sbLeftover.Length > 0) { repStringLeftover = new RepString(repString.fontProp, sbLeftover.ToString()); } else { repStringLeftover = null; } if (sb.Length > 0) { repString = new RepString(repString.fontProp, sb.ToString()); } else { repString = null; } }
/// <summary> /// Método para montar o Rodapé /// </summary> private void MontaRodape() { double linha = 270; Root.Reports.FontProp fontProp = new Root.Reports.FontProp(this.FontDefin, 5); this.InsereLinhaContinua(8, linha, 194, 2, true); linha = linha + 5; fontProp.bBold = true; this.PaginaPDF.AddCB_MM(linha, new Root.Reports.RepString(fontProp, "GRADUAL CORRETORA DE CÂMBIO, TÍTULOS E VALORES MOBILIÁRIOS S/A")); fontProp.bBold = false; string tx = "C.N.P.J: 33.918.160/0001-73"; linha = linha + 3; this.PaginaPDF.AddCB_MM(linha, new Root.Reports.RepString(fontProp, tx)); tx = "Avenida Presidente Juscelino Kubitschek - 50, 6º andar - Vila Nova Conceição - São Paulo - SP - 04543-011"; linha = linha + 3; this.PaginaPDF.AddCB_MM(linha, new Root.Reports.RepString(fontProp, tx)); tx = "Ouvidoria/SAC: 0800 655 1466 | gradualinvestimentos.com.br"; linha = linha + 3; this.PaginaPDF.AddCB_MM(linha, new Root.Reports.RepString(fontProp, tx)); fontProp.bUnderline = false; }
protected void BreakByLetter(ref RepString repString, out RepString repStringLeftover, double rWidth) { FontProp fp = repString.fontProp; StringBuilder sb = new StringBuilder(); StringBuilder sbLeftover = new StringBuilder(); double r_X = 0; foreach (char c in repString.sText) { r_X += fp.rWidth(Convert.ToString(c)); if (r_X <= rWidth) { sb.Append(c); } else { sbLeftover.Append(c); } } if (sbLeftover.Length > 0) { repStringLeftover = new RepString(repString.fontProp, sbLeftover.ToString()); } else { repStringLeftover = null; } if (sb.Length > 0) { repString = new RepString(repString.fontProp, sb.ToString()); } else { repString = null; } }
//------------------------------------------------------------------------------------------06.03.2005 /// <summary>Gets the height of the font in points (1/72 inch).</summary> /// <param name="fontProp">Font properties</param> /// <returns>Height of the font in points (1/72 inch)</returns> internal protected abstract Double rHeight(FontProp fontProp);
//----------------------------------------------------------------------------------------------------x /// <summary>Adds a report object to the current container at the current position.</summary> /// <param name="al_RepObj">Result array for the report objects</param> /// <param name="repString">Report object to add to the container</param> /// <param name="rCurX"></param> /// <param name="rOfsX"></param> /// <param name="rAlignH">Horizontal allignment</param> /// <param name="rCurY"></param> /// <param name="rWidth"></param> internal void FormatString(ArrayList al_RepObj, RepString repString, ref Double rCurX, Double rOfsX, Double rAlignH, ref Double rCurY, Double rWidth) { FontProp fp = repString.fontProp; String sText = repString.sText; Int32 iLineStartIndex = 0; Int32 iIndex = 0; while (true) { Int32 iLineBreakIndex = 0; Double rPosX = rCurX; Double rLineBreakPos = 0; while (true) { if (iIndex >= sText.Length) { iLineBreakIndex = iIndex; rLineBreakPos = rPosX; break; } Char c = sText[iIndex]; if (c == '\r') { iLineBreakIndex = iIndex; iIndex++; c = sText[iIndex]; if (c == '\n') { iIndex++; } break; } rPosX += fp.rGetTextWidth(Convert.ToString(c)); if (rPosX >= rWidth) { if (iLineBreakIndex == 0 && rCurX <= rOfsX + 0.01) { if (iIndex == iLineStartIndex) // at least one character must be printed { iIndex++; } iLineBreakIndex = iIndex; break; } iIndex = iLineBreakIndex; break; } if (c == ' ') { iLineBreakIndex = iIndex + 1; rLineBreakPos = rPosX; } iIndex++; } if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object { repString.matrixD.rDX = rCurX + (rWidth - rCurX) * rAlignH; repString.rAlignH = rAlignH; repString.matrixD.rDY = rCurY; repString.rAlignV = RepObj.rAlignBottom; al_RepObj.Add(repString); rCurX = rLineBreakPos; break; } if (iLineBreakIndex > iLineStartIndex && sText[iLineBreakIndex - 1] == ' ') { iLineBreakIndex--; } String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex); RepString rs = new RepString(fp, sLine); rs.matrixD.rDX = rCurX + (rWidth - rCurX) * rAlignH; rs.rAlignH = rAlignH; rs.matrixD.rDY = rCurY; rs.rAlignV = RepObj.rAlignBottom; al_RepObj.Add(rs); if (iIndex >= sText.Length) { rCurX = rLineBreakPos; break; } rCurX = rOfsX; rCurY += fp.rLineFeed; iLineStartIndex = iIndex; } }
//----------------------------------------------------------------------------------------------------x /// <summary>Adds a report object to the current container at the current position.</summary> /// <param name="repString">Report object to add to the container</param> /// <param name="container">Container</param> /// <param name="rCurX"></param> /// <param name="rOfsX"></param> /// <param name="rCurY"></param> /// <param name="rWidth"></param> public void PrintString(RepString repString, Container container, ref Double rCurX, Double rOfsX, ref Double rCurY, Double rWidth) { FontProp fp = repString.fontProp; String sText = repString.sText; Int32 iLineStartIndex = 0; Int32 iIndex = 0; while (true) { if (rCurY > container.rHeight) { NextContainer(); } Int32 iLineBreakIndex = 0; Double rPosX = rCurX; Double rLineBreakPos = 0; while (true) { if (iIndex >= sText.Length) { iLineBreakIndex = iIndex; rLineBreakPos = rPosX; break; } Char c = sText[iIndex]; rPosX += fp.rGetTextWidth(Convert.ToString(c)); if (rPosX >= rWidth) { if (iLineBreakIndex == 0) { if (iIndex == iLineStartIndex) // at least one character must be printed { iIndex++; } iLineBreakIndex = iIndex; break; } iIndex = iLineBreakIndex; break; } if (c == ' ') { iLineBreakIndex = iIndex + 1; rLineBreakPos = rPosX; } else if (c == '\n') { iLineBreakIndex = iIndex; iIndex++; break; } iIndex++; } if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object { container.Add(rOfsX + rCurX, rCurY, repString); rCurX = rLineBreakPos; break; } String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex); container.Add(rOfsX + rCurX, rCurY, new RepString(fp, sLine)); if (iIndex >= sText.Length) { rCurX = rLineBreakPos; break; } rCurX = 0; rCurY += fp.rLineFeed; iLineStartIndex = iIndex; } }
//------------------------------------------------------------------------------------------03.02.2005 #region Methods //---------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------03.02.2005 /// <summary>Resets the prepared data structures.</summary> /// <remarks>This operation is required if any property of the font changes.</remarks> private void ResetPreparedData() { System.Diagnostics.Debug.Assert(!bRegistered); _fontProp_Registered = null; }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new DateTime object.</summary> /// <param name="fontProp">Font properties of the DateTime object</param> /// <param name="dt_Val">DateTime value</param> public RepDateTime(FontProp fontProp, DateTime dt_Val) : base(fontProp, dt_Val.ToString()) { }
public void AddBlock(FontProp fp, string s) { AddBlock(new RepObj[] { new RepString(fp, s) }); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new RepReal32 object.</summary> /// <param name="fontProp">Font properties of the Real32 object</param> /// <param name="fVal">Real32 (Single) value</param> /// <param name="nfi">Provides the format information for the Int32 value (ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemGlobalizationNumberFormatInfoClassTopic.htm)</param> public RepReal32(FontProp fontProp, Single fVal, NumberFormatInfo nfi) : base(fontProp, String.Format(nfi, "{0:N}", fVal)) { }
//----------------------------------------------------------------------------------------------------x /// <summary>Prepares the PDF-object structure for a container.</summary> /// <param name="pdfPageData"></param> /// <param name="iObjId"></param> /// <param name="container"></param> private void PrepareObjIdsForContainer(PdfIndirectObject_Page pdfPageData, Container container) { foreach (RepObj repObj in container) { if (repObj is Container) { PrepareObjIdsForContainer(pdfPageData, (Container)repObj); } else if (repObj is RepArcBase) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepImage) { // RepImage repImage = (RepImage)repObj; // ImageFormat imageFormat = repImage.imageData.image.RawFormat; // if (Object.Equals(imageFormat, ImageFormat.Jpeg)) { // pdfPageData.bProcSet_ImageC = true; // } // else if (Object.Equals(imageFormat, ImageFormat.Tiff)) { // pdfPageData.bProcSet_ImageB = true; // } // else { // Debug.Fail("unknown image type: send image to [email protected]"); // } RepImage repImage = repObj as RepImage; repImage.imageData.stream.Position = 0; //Added By TechnoGuru - [email protected] - http://www.borie.org/ //To support tiff file //I reload Image from stream to be more scalable //(Dont't have like that lots of image object on memeory #if !WindowsCE using (Image image = Image.FromStream(repImage.imageData.stream)) { if (image.RawFormat.Equals(ImageFormat.Tiff) && image.PixelFormat.Equals(PixelFormat.Format1bppIndexed)) { pdfPageData.bProcSet_ImageI = true; // CHANGED } else if (image.RawFormat.Equals(ImageFormat.Tiff) || image.RawFormat.Equals(ImageFormat.Jpeg)) { pdfPageData.bProcSet_ImageC = true; } else { Debug.Fail("unknown image type: send image to [email protected]"); } } #endif } else if (repObj is RepLine) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepRect) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepString) { FontProp fontProp_String = ((RepString)repObj).fontProp; PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp_String.fontPropData; if (pdfFontPropData.pdfIndirectObject_Font == null) { pdfFontPropData.pdfIndirectObject_Font = new PdfIndirectObject_Font(this, fontProp_String); } pdfPageData.RegisterFontProp(fontProp_String); pdfPageData.bProcSet_Text = true; } else { throw new ReportException("unknown report object type [" + repObj.GetType().FullName + "]"); } } }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new RepReal64 object.</summary> /// <param name="fontProp">Font properties of the Real64 object</param> /// <param name="rVal">Real64 value</param> /// <param name="sFormat">Provides the format information for the Int32 value (ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconcustomnumericformatstrings.htm)</param> public RepReal64(FontProp fontProp, Double rVal, String sFormat) : base(fontProp, rVal.ToString(sFormat)) { }
private void MontaBarraTitulo(double linha, string titulo) { Root.Reports.FontProp fontProp = new Root.Reports.FontProp(this.FontDefin, 6, System.Drawing.Color.WhiteSmoke); this.PaginaPDF.AddCB_MM(105, linha, new Root.Reports.RepString(fontProp, titulo)); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new RepReal64 object.</summary> /// <param name="fontProp">Font properties of the Real64 object</param> /// <param name="rVal">Real64 value</param> /// <param name="nfi">Provides the format information for the Int32 value (ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemGlobalizationNumberFormatInfoClassTopic.htm)</param> //public RepReal64(FontProp fontProp, Double rVal, NumberFormatInfo nfi) : base(fontProp, rVal.ToString(nfi)) { public RepReal64(FontProp fontProp, Double rVal, NumberFormatInfo nfi) : base(fontProp, String.Format(nfi, "{0:N}", rVal)) { }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new RepReal64 object.</summary> /// <param name="fontProp">Font properties of the Real64 object</param> /// <param name="rVal">Real64 value</param> public RepReal64(FontProp fontProp, Double rVal) : base(fontProp, rVal.ToString("0.00")) { }
//------------------------------------------------------------------------------------------06.03.2005 /// <summary>Gets the width of the specified text in points (1/72 inch).</summary> /// <param name="fontProp">Font properties</param> /// <param name="sText">Text</param> /// <returns>Width of the text in points (1/72 inch)</returns> internal protected abstract Double rWidth(FontProp fontProp, String sText);
private PdfIndirectObject_Page _pdfPageData_Registered; // !!! variable name //----------------------------------------------------------------------------------------------------x /// <summary></summary> /// <param name="sKey"></param> /// <param name="afm"></param> public PdfFontPropX(String sKey, FontProp fontProp) : base() { this.sKey = sKey; }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new RepReal32 object.</summary> /// <param name="fontProp">Font properties of the Real32 object</param> /// <param name="fVal">Real32 (Single) value</param> public RepReal32(FontProp fontProp, Single fVal) : base(fontProp, fVal.ToString("0.00")) { }
//----------------------------------------------------------------------------------------------------x /// <summary>Adds a report object to the current container at the current position.</summary> /// <param name="repObj">Report object to add to the container</param> public void Add(RepObj repObj) { if (status == Status.Init) { if (_container_Cur == null) { CreateNewContainer(); } } if (repObj is RepString) { RepString repString = (RepString)repObj; FontProp fp = repString.fontProp; String sText = repString.sText; Int32 iLineStartIndex = 0; Int32 iIndex = 0; while (true) { if (rY_Cur > container_Cur.rHeight) { _container_Cur = null; CreateNewContainer(); } Int32 iLineBreakIndex = 0; Double rPosX = rX_Cur; Double rLineBreakPos = 0; while (true) { if (iIndex >= sText.Length) { iLineBreakIndex = iIndex; rLineBreakPos = rPosX; break; } Char c = sText[iIndex]; rPosX += fp.rWidth(Convert.ToString(c)); if (rPosX >= container_Cur.rWidth) { if (iLineBreakIndex == 0) { if (iIndex == iLineStartIndex) // at least one character must be printed { iIndex++; } iLineBreakIndex = iIndex; break; } iIndex = iLineBreakIndex; break; } if (c == ' ') { iLineBreakIndex = iIndex + 1; rLineBreakPos = rPosX; } else if (c == '\n') { iLineBreakIndex = iIndex; iIndex++; break; } iIndex++; } if (iLineStartIndex == 0 && iIndex >= sText.Length) // add entire object { container_Cur.Add(rX_Cur, rY_Cur, repObj); rX_Cur = rLineBreakPos; break; } String sLine = sText.Substring(iLineStartIndex, iLineBreakIndex - iLineStartIndex); container_Cur.Add(rX_Cur, rY_Cur, new RepString(fp, sLine)); if (iIndex >= sText.Length) { rX_Cur = rLineBreakPos; break; } rX_Cur = 0; rY_Cur += fp.rLineFeed; iLineStartIndex = iIndex; } } else { Debug.Fail("Unknown object type"); container_Cur.Add(rX_Cur, rY_Cur, repObj); } }
//----------------------------------------------------------------------------------------------------x /// <summary>Gets the width of the specified text with this font in 1/72 inches.</summary> /// <param name="fontProp">Font properties</param> /// <param name="sText">Text</param> /// <returns>Width of the text in 1/72 inches</returns> internal protected override Double rWidth(FontProp fontProp, String sText) { // return rSizeFactor(fontProp) * fontData.rRawWidth(sText) / 1000; return(0); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new table layout manager.</summary> /// <param name="fp_Header">Font property of the header</param> public TableLayoutManager(FontProp fontProp_Header) : this(fontProp_Header.fontDef.report) { this.fontProp_Header = fontProp_Header; }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a new DateTime object.</summary> /// <param name="fontProp">Font properties of the DateTime object</param> /// <param name="dt_Val">DateTime value</param> /// <param name="sFormat">Provides the format information for the DataTime value (ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemGlobalizationDateTimeFormatInfoClassTopic.htm)</param> public RepDateTime(FontProp fontProp, DateTime dt_Val, String sFormat) : base(fontProp, dt_Val.ToString(sFormat)) { }