Пример #1
0
        /// <summary>
        /// Renderiza o Bloco em uma Página.
        /// </summary>
        /// <param name="p_font">Fonte.</param>
        /// <param name="p_posx">Posição X.</param>
        /// <param name="p_posy">Posição Y.</param>
        /// <param name="p_rightmargin">Margem direita.</param>
        /// <param name="p_pdf">Objeto PDF.</param>
        /// <param name="p_page">Página onde o Bloco será renderizado.</param>
        public void Render(Spartacus.Reporting.Font p_font, double p_posx, double p_posy, double p_rightmargin, PDFjet.NET.PDF p_pdf, PDFjet.NET.Page p_page)
        {
            PDFjet.NET.Line v_line;
            int k;

            // renderizando objetos do bloco
            for (k = 0; k < this.v_objects.Count; k++)
            {
                switch (((Spartacus.Reporting.Object)this.v_objects [k]).v_type)
                {
                    case Spartacus.Reporting.ObjectType.IMAGE:
                        this.RenderImage((Spartacus.Reporting.Object)this.v_objects [k], p_posx, p_posy, p_rightmargin, p_pdf, p_page);
                        break;
                    case Spartacus.Reporting.ObjectType.PAGENUMBER:
                        if (((Spartacus.Reporting.Object)this.v_objects [k]).v_font != null)
                            this.RenderPageNumber((Spartacus.Reporting.Object)this.v_objects [k], p_posx, p_posy, p_rightmargin, ((Spartacus.Reporting.Object)this.v_objects [k]).v_font, p_pdf, p_page);
                        else
                            this.RenderPageNumber((Spartacus.Reporting.Object)this.v_objects [k], p_posx, p_posy, p_rightmargin, p_font, p_pdf, p_page);
                        break;
                    case Spartacus.Reporting.ObjectType.TEXT:
                        if (((Spartacus.Reporting.Object)this.v_objects [k]).v_font != null)
                            this.RenderText((Spartacus.Reporting.Object)this.v_objects [k], p_posx, p_posy, p_rightmargin, ((Spartacus.Reporting.Object)this.v_objects [k]).v_font, p_pdf, p_page);
                        else
                            this.RenderText((Spartacus.Reporting.Object)this.v_objects [k], p_posx, p_posy, p_rightmargin, p_font, p_pdf, p_page);
                        break;
                    default:
                        break;
                }
            }

            // borda superior
            if (this.v_border.v_top)
            {
                v_line = new PDFjet.NET.Line(p_posx, p_posy, p_page.GetWidth() - p_rightmargin, p_posy);
                v_line.DrawOn(p_page);
            }

            // borda inferior
            if (this.v_border.v_bottom)
            {
                v_line = new PDFjet.NET.Line(p_posx, p_posy + this.v_height, p_page.GetWidth() - p_rightmargin, p_posy + this.v_height);
                v_line.DrawOn(p_page);
            }

            // borda esquerda
            if (this.v_border.v_left)
            {
                v_line = new PDFjet.NET.Line(p_posx, p_posy, p_posx, p_posy + this.v_height);
                v_line.DrawOn(p_page);
            }

            // borda direita
            if (this.v_border.v_right)
            {
                v_line = new PDFjet.NET.Line(p_page.GetWidth() - p_rightmargin, p_posy, p_page.GetWidth() - p_rightmargin, p_posy + this.v_height);
                v_line.DrawOn(p_page);
            }
        }
Пример #2
0
 //-------------------------------------------------------------------------------------------
 private void DrawText(PDFjet.NET.PDF pdf, PDFjet.NET.Page page, string text, int x, int y)
 {
     Font f1 = new Font(pdf, "Helvetica");
        f1.SetSize(10);
        PDFjet.NET.TextLine tLine = new TextLine(f1);
        tLine.SetText(text);
        tLine.SetPosition(x, y);
        //tLine.SetURIAction("http://www.weavver.com/accounting/");
        tLine.DrawOn(page);
 }
        /// <summary>
        /// Contrói modelos de renderização em memória.
        /// </summary>
        /// <param name="p_pageheight">Altura da página.</param>
        /// <param name="p_pagewidth">Largura da página.</param>
        /// <param name="p_datafieldfont">Fonte do campo de dados.</param>
        /// <param name="p_groupheaderfont">Fonte do cabeçalho de grupo.</param>
        /// <param name="p_groupfooterfont">Fonte do rodapé de grupo.</param>
        private void BuildTemplates(
            float p_pageheight,
            float p_pagewidth,
            PDFjet.NET.Font p_datafieldfont,
            PDFjet.NET.Font p_groupheaderfont,
            PDFjet.NET.Font p_groupfooterfont
        )
        {
            System.Collections.Generic.List<PDFjet.NET.Cell> v_row;
            PDFjet.NET.Cell v_cell;
            Spartacus.Reporting.Group v_group;
            int k, r, v_sectionrow, v_level;

            // modelo do detalhe ímpar

            this.v_detailoddtemplate = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();

            for (v_sectionrow = 0; v_sectionrow < this.v_numrowsdetail; v_sectionrow++)
            {
                v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                for (k = 0; k < this.v_fields.Count; k++)
                {
                    if (((Spartacus.Reporting.Field)this.v_fields[k]).v_row == v_sectionrow)
                    {
                        v_cell = new PDFjet.NET.Cell(p_datafieldfont);
                        v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)this.v_fields[k]).v_fill) / 100);
                        switch (((Spartacus.Reporting.Field)this.v_fields[k]).v_align)
                        {
                            case Spartacus.Reporting.FieldAlignment.LEFT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.RIGHT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.CENTER:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                break;
                            default:
                                break;
                        }
                        v_cell.SetBgColor(this.v_settings.v_datafieldoddcolor);
                        if (((Spartacus.Reporting.Field)this.v_fields[k]).v_border != null)
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_top || this.v_settings.v_datafieldborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_bottom || this.v_settings.v_datafieldborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_left || this.v_settings.v_datafieldborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_right || this.v_settings.v_datafieldborder.v_right);
                        }
                        else
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_datafieldborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_datafieldborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_datafieldborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_datafieldborder.v_right);
                        }
                        v_row.Add(v_cell);
                    }
                }
                this.v_detailoddtemplate.Add(v_row);
            }

            // modelo do detalhe par

            this.v_detaileventemplate = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();

            for (v_sectionrow = 0; v_sectionrow < this.v_numrowsdetail; v_sectionrow++)
            {
                v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                for (k = 0; k < this.v_fields.Count; k++)
                {
                    if (((Spartacus.Reporting.Field)this.v_fields[k]).v_row == v_sectionrow)
                    {
                        v_cell = new PDFjet.NET.Cell(p_datafieldfont);
                        v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)this.v_fields[k]).v_fill) / 100);
                        switch (((Spartacus.Reporting.Field)this.v_fields[k]).v_align)
                        {
                            case Spartacus.Reporting.FieldAlignment.LEFT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.RIGHT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.CENTER:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                break;
                            default:
                                break;
                        }
                        v_cell.SetBgColor(this.v_settings.v_datafieldevencolor);
                        if (((Spartacus.Reporting.Field)this.v_fields[k]).v_border != null)
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_top || this.v_settings.v_datafieldborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_bottom || this.v_settings.v_datafieldborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_left || this.v_settings.v_datafieldborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_right || this.v_settings.v_datafieldborder.v_right);
                        }
                        else
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_datafieldborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_datafieldborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_datafieldborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_datafieldborder.v_right);
                        }
                        v_row.Add(v_cell);
                    }
                }
                this.v_detaileventemplate.Add(v_row);
            }

            for (v_level = 0; v_level < this.v_groups.Count; v_level++)
            {
                v_group = (Spartacus.Reporting.Group)this.v_groups[v_level];

                // modelo do cabeçalho do grupo

                if (v_group.v_showheader)
                {
                    v_group.v_headertemplate = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();

                    r = 0;
                    for (v_sectionrow = 0; v_sectionrow < v_group.v_numrowsheader; v_sectionrow++)
                    {
                        v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                        for (k = 0; k < v_group.v_headerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_row == v_sectionrow)
                            {
                                v_cell = new PDFjet.NET.Cell(p_groupheaderfont);
                                v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_fill) / 100);
                                switch (((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_align)
                                {
                                    case Spartacus.Reporting.FieldAlignment.LEFT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.RIGHT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.CENTER:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                        break;
                                    default:
                                        break;
                                }
                                if (r % 2 == 0)
                                    v_cell.SetBgColor(this.v_settings.v_groupheaderevencolor);
                                else
                                    v_cell.SetBgColor(this.v_settings.v_groupheaderoddcolor);
                                if (((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_border != null)
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_border.v_top || this.v_settings.v_groupheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_border.v_bottom || this.v_settings.v_groupheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_border.v_left || this.v_settings.v_groupheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_border.v_right || this.v_settings.v_groupheaderborder.v_right);
                                }
                                else
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_groupheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_groupheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_groupheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_groupheaderborder.v_right);
                                }
                                v_row.Add(v_cell);
                            }
                        }
                        v_group.v_headertemplate.Add(v_row);
                        r++;
                    }
                }

                // modelo do rodapé grupo

                if (v_group.v_showfooter)
                {
                    v_group.v_footertemplate = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();

                    r = 0;
                    for (v_sectionrow = 0; v_sectionrow < v_group.v_numrowsfooter; v_sectionrow++)
                    {
                        v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                        for (k = 0; k < v_group.v_footerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_row == v_sectionrow)
                            {
                                v_cell = new PDFjet.NET.Cell(p_groupfooterfont);
                                v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_fill) / 100);
                                switch (((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_align)
                                {
                                    case Spartacus.Reporting.FieldAlignment.LEFT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.RIGHT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.CENTER:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                        break;
                                    default:
                                        break;
                                }
                                if (r % 2 == 0)
                                    v_cell.SetBgColor(this.v_settings.v_groupfooterevencolor);
                                else
                                    v_cell.SetBgColor(this.v_settings.v_groupfooteroddcolor);
                                if (((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_border != null)
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_border.v_top || this.v_settings.v_groupfooterborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_border.v_bottom || this.v_settings.v_groupfooterborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_border.v_left || this.v_settings.v_groupfooterborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_border.v_right || this.v_settings.v_groupfooterborder.v_right);
                                }
                                else
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_groupfooterborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_groupfooterborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_groupfooterborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_groupfooterborder.v_right);
                                }
                                v_row.Add(v_cell);
                            }
                        }
                        v_group.v_footertemplate.Add(v_row);
                        r++;
                    }
                }
            }
        }
        /// <summary>
        /// Salva como PDF parcialmente.
        /// Usado para renderização de pacotes de arquivos PDF.
        /// </summary>
        /// <param name="p_pdf">Objeto PDF aberto.</param>
        public void SavePartial(PDFjet.NET.PDF p_pdf)
        {
            PDFjet.NET.Table v_dataheadertable = null, v_datatable;
            float[] v_layout;
            PDFjet.NET.Page v_page;
            System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> v_rendered;
            int v_numpages, v_currentpage;
            Spartacus.Utils.Cryptor v_cryptor;
            string v_datafilename;
            System.IO.StreamReader v_reader;

            // se o relatório não tiver dados, não faz nada
            if (this.v_table.Rows.Count == 0)
                return;

            try
            {
                this.v_progress.FireEvent("Spartacus.Reporting.Report", "ExportPDF", this.v_perc, "Renderizando o relatorio " + this.v_reportid.ToString());
                this.v_inc = this.v_percstep / (double) this.v_table.Rows.Count;
                this.v_renderedrows = 0;

                if (this.v_settings.v_layout == Spartacus.Reporting.PageLayout.LANDSCAPE)
                    v_layout = PDFjet.NET.A4.LANDSCAPE;
                else
                    v_layout = PDFjet.NET.A4.PORTRAIT;

                v_page = new PDFjet.NET.Page(p_pdf, v_layout);

                // tabela de cabecalho de dados

                if (this.v_settings.v_showdataheader)
                {
                    v_dataheadertable = new PDFjet.NET.Table();
                    v_dataheadertable.SetPosition(this.v_settings.v_leftmargin, this.v_settings.v_topmargin  + this.v_header.v_height);

                    v_rendered = this.RenderDataHeader(
                        v_page.GetHeight(),
                        v_page.GetWidth(),
                        this.v_settings.v_dataheaderfont.GetFont(p_pdf)
                    );

                    v_dataheadertable.SetData(v_rendered, PDFjet.NET.Table.DATA_HAS_0_HEADER_ROWS);
                    //v_dataheadertable.SetCellBordersWidth(1.5f);
                }

                // tabela de dados

                v_datatable = new PDFjet.NET.Table();
                //v_datatable.SetPosition(this.v_settings.v_leftmargin, this.v_settings.v_topmargin  + this.v_header.v_height + ((this.v_settings.v_dataheaderfont.v_size + 2) * 1.8 * this.v_numrowsdetail));
                if (this.v_settings.v_showdataheader)
                    v_datatable.SetPosition(this.v_settings.v_leftmargin, this.v_settings.v_topmargin  + this.v_header.v_height + ((this.v_settings.v_dataheaderfont.v_size + 2) * 1.8 * this.v_numrowsdataheader));
                else
                    v_datatable.SetPosition(this.v_settings.v_leftmargin, this.v_settings.v_topmargin  + this.v_header.v_height);
                v_datatable.SetBottomMargin(this.v_settings.v_bottommargin + this.v_footer.v_height);

                this.BuildTemplates(
                    v_page.GetHeight(),
                    v_page.GetWidth(),
                    this.v_settings.v_datafieldfont.GetFont(p_pdf),
                    this.v_settings.v_groupheaderfont.GetFont(p_pdf),
                    this.v_settings.v_groupfooterfont.GetFont(p_pdf)
                );

                v_cryptor = new Spartacus.Utils.Cryptor("spartacus");
                v_datafilename = v_cryptor.RandomString() + ".tmp";
                this.v_datafile = System.IO.File.Open(
                    v_datafilename,
                    System.IO.FileMode.Create,
                    System.IO.FileAccess.ReadWrite
                );

                v_rendered = this.RenderData(
                    v_page.GetHeight(),
                    v_page.GetWidth(),
                    this.v_settings.v_datafieldfont.GetFont(p_pdf),
                    this.v_settings.v_groupheaderfont.GetFont(p_pdf),
                    this.v_settings.v_groupfooterfont.GetFont(p_pdf)
                );

                v_datatable.SetData(v_rendered, PDFjet.NET.Table.DATA_HAS_0_HEADER_ROWS);
                //v_datatable.SetCellBordersWidth(1.5f);

                this.v_datafile.Seek(0, System.IO.SeekOrigin.Begin);
                v_reader = new System.IO.StreamReader(this.v_datafile);

                // salvando PDF

                this.v_header.SetValues(this.v_table);
                this.v_footer.SetValues(this.v_table);

                v_numpages = v_datatable.GetNumberOfPages(v_page);
                v_currentpage = 1;
                while (v_datatable.HasMoreData())
                {
                    this.v_header.SetPageNumber(v_currentpage, v_numpages);
                    this.v_footer.SetPageNumber(v_currentpage, v_numpages);

                    this.v_header.Render(
                        this.v_settings.v_reportheaderfont,
                        this.v_settings.v_leftmargin,
                        this.v_settings.v_topmargin,
                        this.v_settings.v_rightmargin,
                        p_pdf,
                        v_page
                    );

                    if (this.v_settings.v_showdataheader)
                        v_dataheadertable.DrawOn(v_page);
                    v_datatable.ImprovedDrawOn(v_page, v_reader);

                    this.v_footer.Render(
                        this.v_settings.v_reportfooterfont,
                        this.v_settings.v_leftmargin,
                        v_page.GetHeight() - v_settings.v_bottommargin - v_footer.v_height,
                        this.v_settings.v_rightmargin,
                        p_pdf,
                        v_page
                    );

                    if (v_datatable.HasMoreData())
                    {
                        if (this.v_settings.v_showdataheader)
                            v_dataheadertable.ResetRenderedPagesCount();

                        v_page = new PDFjet.NET.Page(p_pdf, v_layout);
                        v_currentpage++;
                    }
                }

                v_reader.Close();
                this.v_datafile.Close();
                (new System.IO.FileInfo(v_datafilename)).Delete();

                this.v_perc = this.v_lastperc;
                this.v_progress.FireEvent("Spartacus.Reporting.Report", "ExportPDF", this.v_perc, "Relatorio " + this.v_reportid.ToString() + " renderizado.");
            }
            catch (System.Exception e)
            {
                throw new Spartacus.Reporting.Exception("Erro ao gerar o arquivo PDF de saída.", e);
            }
        }
        /// <summary>
        /// Renderiza um grupo.
        /// </summary>
        /// <param name="p_level">Nível do grupo atual.</param>
        /// <param name="p_parentgroupcolumn">Coluna do grupo pai.</param>
        /// <param name="p_parentgroupvalue">Valor do grupo pai.</param>
        /// <param name="p_data">Matriz de dados.</param>
        /// <param name="p_pageheight">Altura da página.</param>
        /// <param name="p_pagewidth">Largura da página.</param>
        /// <param name="p_datafieldfont">Fonte do campo de dados.</param>
        /// <param name="p_groupheaderfont">Fonte do cabeçalho de grupo.</param>
        /// <param name="p_groupfooterfont">Fonte do rodapé de grupo.</param>
        private void RenderGroup(
            int p_level,
            string p_parentgroupcolumn,
            string p_parentgroupvalue,
            System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> p_data,
            float p_pageheight,
            float p_pagewidth,
            PDFjet.NET.Font p_datafieldfont,
            PDFjet.NET.Font p_groupheaderfont,
            PDFjet.NET.Font p_groupfooterfont,
            System.IO.StreamWriter p_writer
        )
        {
            Spartacus.Reporting.Group v_group;
            string v_textrow;
            string v_text;
            int k, r, v_sectionrow;
            System.Data.DataRow rg, rb;

            v_group = (Spartacus.Reporting.Group)this.v_groups [p_level];

            // percorrendo elementos do grupo
            rg = v_group.v_table.Rows[v_group.v_renderedrows];
            while (v_group.v_renderedrows < v_group.v_table.Rows.Count &&
                   (v_group.v_level == this.v_groups.Count-1 ||
                    rg[p_parentgroupcolumn].ToString() == p_parentgroupvalue))
            {
                // renderizando campos do cabecalho
                if (v_group.v_showheader)
                {
                    for (v_sectionrow = 0; v_sectionrow < v_group.v_numrowsheader; v_sectionrow++)
                    {
                        v_textrow = "";
                        for (k = 0; k < v_group.v_headerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_row == v_sectionrow)
                            {
                                if (((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_column != "")
                                    v_text = ((Spartacus.Reporting.Field)v_group.v_headerfields[k]).Format(rg[((Spartacus.Reporting.Field)v_group.v_headerfields[k]).v_column].ToString());
                                else
                                    v_text = "";
                                v_textrow += v_text.Replace(';', ',').Replace('\n', ' ').Replace('\r', ' ') + ";";
                            }
                        }
                        p_writer.WriteLine(v_textrow);
                    }

                    p_data.AddRange(v_group.v_headertemplate);
                }

                if (v_group.v_level == 0)
                {
                    // renderizando dados do grupo
                    r = 0;
                    rb = this.v_rendertable.Rows[this.v_renderedrows];
                    while (this.v_renderedrows < this.v_rendertable.Rows.Count &&
                           rb[v_group.v_column].ToString() == rg[v_group.v_column].ToString() &&
                           (v_group.v_level == this.v_groups.Count-1 ||
                            rb[p_parentgroupcolumn].ToString() == p_parentgroupvalue))
                    {
                        for (v_sectionrow = 0; v_sectionrow < this.v_numrowsdetail; v_sectionrow++)
                        {
                            v_textrow = "";
                            for (k = 0; k < this.v_fields.Count; k++)
                            {
                                if (((Spartacus.Reporting.Field)this.v_fields[k]).v_row == v_sectionrow)
                                {
                                    v_text = ((Spartacus.Reporting.Field)this.v_fields[k]).Format(rb[((Spartacus.Reporting.Field)this.v_fields[k]).v_column].ToString());
                                    v_textrow += v_text.Replace(';', ',').Replace('\n', ' ').Replace('\r', ' ') + ";";
                                }
                            }
                            p_writer.WriteLine(v_textrow);
                        }

                        if (r % 2 == 0)
                            p_data.AddRange(this.v_detaileventemplate);
                        else
                            p_data.AddRange(this.v_detailoddtemplate);
                        r++;

                        this.v_perc += v_inc;
                        this.v_renderedrows++;
                        this.v_progress.FireEvent("Spartacus.Reporting.Report", "ExportPDF", this.v_perc, "Relatorio " + this.v_reportid.ToString() + ": linha " + this.v_renderedrows.ToString() + " de " + this.v_table.Rows.Count.ToString());

                        if (this.v_renderedrows < this.v_rendertable.Rows.Count)
                            rb = this.v_rendertable.Rows[this.v_renderedrows];
                    }
                }
                else
                {
                    this.RenderGroup(
                        p_level - 1,
                        v_group.v_column,
                        rg[v_group.v_column].ToString(),
                        p_data,
                        p_pageheight,
                        p_pagewidth,
                        p_datafieldfont,
                        p_groupheaderfont,
                        p_groupfooterfont,
                        p_writer
                    );
                }

                // renderizando campos do rodape
                if (v_group.v_showfooter)
                {
                    for (v_sectionrow = 0; v_sectionrow < v_group.v_numrowsfooter; v_sectionrow++)
                    {
                        v_textrow = "";
                        for (k = 0; k < v_group.v_footerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_row == v_sectionrow)
                            {
                                if (((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_column != "")
                                    v_text = ((Spartacus.Reporting.Field)v_group.v_footerfields[k]).Format(rg[((Spartacus.Reporting.Field)v_group.v_footerfields[k]).v_column].ToString());
                                else
                                    v_text = "";
                                v_textrow += v_text.Replace(';', ',').Replace('\n', ' ').Replace('\r', ' ') + ";";
                            }
                        }
                        p_writer.WriteLine(v_textrow);
                    }

                    p_data.AddRange(v_group.v_footertemplate);
                }

                v_group.v_renderedrows++;
                if (v_group.v_renderedrows < v_group.v_table.Rows.Count)
                    rg = v_group.v_table.Rows[v_group.v_renderedrows];
            }
        }
        /// <summary>
        /// Renderiza cabeçalho de dados.
        /// </summary>
        /// <returns>Matriz representando o cabeçalho de dados.</returns>
        /// <param name="p_pageheight">Altura da página.</param>
        /// <param name="p_pagewidth">Largura da página.</param>
        /// <param name="p_dataheaderfont">Fonte do cabeçalho de dados.</param>
        private System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> RenderDataHeader(
            float p_pageheight,
            float p_pagewidth,
            PDFjet.NET.Font p_dataheaderfont
        )
        {
            System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> v_data;
            System.Collections.Generic.List<PDFjet.NET.Cell> v_row;
            PDFjet.NET.Cell v_cell;
            int g, k, v_sectionrow;

            v_data = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();
            this.v_numrowsdataheader = 0;

            for (g = this.v_groups.Count - 1; g >= 0; g--)
            {
                // renderizando titulos de cabeçalhos de grupos
                if (((Spartacus.Reporting.Group)this.v_groups[g]).v_showheadertitles)
                {
                    this.v_numrowsdataheader += ((Spartacus.Reporting.Group)this.v_groups[g]).v_numrowsheader;

                    for (v_sectionrow = 0; v_sectionrow < ((Spartacus.Reporting.Group)this.v_groups[g]).v_numrowsheader; v_sectionrow++)
                    {
                        v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                        for (k = 0; k < ((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_row == v_sectionrow)
                            {
                                v_cell = new PDFjet.NET.Cell(p_dataheaderfont);
                                v_cell.SetText(((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_title);
                                v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_fill) / 100);
                                switch (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_align)
                                {
                                    case Spartacus.Reporting.FieldAlignment.LEFT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.RIGHT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.CENTER:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                        break;
                                    default:
                                        break;
                                }
                                v_cell.SetBgColor(this.v_settings.v_dataheadercolor);
                                if (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_border != null)
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_border.v_top || this.v_settings.v_dataheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_border.v_bottom || this.v_settings.v_dataheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_border.v_left || this.v_settings.v_dataheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_headerfields[k]).v_border.v_right || this.v_settings.v_dataheaderborder.v_right);
                                }
                                else
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_dataheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_dataheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_dataheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_dataheaderborder.v_right);
                                }
                                v_row.Add(v_cell);
                            }
                        }
                        v_data.Add(v_row);
                    }
                }

                // renderizando titulos de rodapés de grupos
                if (((Spartacus.Reporting.Group)this.v_groups[g]).v_showfootertitles)
                {
                    this.v_numrowsdataheader += ((Spartacus.Reporting.Group)this.v_groups[g]).v_numrowsfooter;

                    for (v_sectionrow = 0; v_sectionrow < ((Spartacus.Reporting.Group)this.v_groups[g]).v_numrowsfooter; v_sectionrow++)
                    {
                        v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                        for (k = 0; k < ((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_row == v_sectionrow)
                            {
                                v_cell = new PDFjet.NET.Cell(p_dataheaderfont);
                                v_cell.SetText(((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_title);
                                v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_fill) / 100);
                                switch (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_align)
                                {
                                    case Spartacus.Reporting.FieldAlignment.LEFT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.RIGHT:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                        break;
                                    case Spartacus.Reporting.FieldAlignment.CENTER:
                                        v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                        break;
                                    default:
                                        break;
                                }
                                v_cell.SetBgColor(this.v_settings.v_dataheadercolor);
                                if (((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_border != null)
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_border.v_top || this.v_settings.v_dataheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_border.v_bottom || this.v_settings.v_dataheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_border.v_left || this.v_settings.v_dataheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)((Spartacus.Reporting.Group)this.v_groups[g]).v_footerfields[k]).v_border.v_right || this.v_settings.v_dataheaderborder.v_right);
                                }
                                else
                                {
                                    v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_dataheaderborder.v_top);
                                    v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_dataheaderborder.v_bottom);
                                    v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_dataheaderborder.v_left);
                                    v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_dataheaderborder.v_right);
                                }
                                v_row.Add(v_cell);
                            }
                        }
                        v_data.Add(v_row);
                    }
                }
            }

            // renderizando titulos de campos de detalhe
            this.v_numrowsdataheader += this.v_numrowsdetail;
            for (v_sectionrow = 0; v_sectionrow < this.v_numrowsdetail; v_sectionrow++)
            {
                v_row = new System.Collections.Generic.List<PDFjet.NET.Cell>();
                for (k = 0; k < this.v_fields.Count; k++)
                {
                    if (((Spartacus.Reporting.Field)this.v_fields[k]).v_row == v_sectionrow)
                    {
                        v_cell = new PDFjet.NET.Cell(p_dataheaderfont);
                        v_cell.SetText(((Spartacus.Reporting.Field)this.v_fields[k]).v_title);
                        v_cell.SetWidth(((p_pagewidth - (this.v_settings.v_leftmargin + this.v_settings.v_rightmargin)) * ((Spartacus.Reporting.Field)this.v_fields[k]).v_fill) / 100);
                        switch (((Spartacus.Reporting.Field)this.v_fields[k]).v_align)
                        {
                            case Spartacus.Reporting.FieldAlignment.LEFT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.LEFT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.RIGHT:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.RIGHT);
                                break;
                            case Spartacus.Reporting.FieldAlignment.CENTER:
                                v_cell.SetTextAlignment(PDFjet.NET.Align.CENTER);
                                break;
                            default:
                                break;
                        }
                        v_cell.SetBgColor(this.v_settings.v_dataheadercolor);
                        if (((Spartacus.Reporting.Field)this.v_fields[k]).v_border != null)
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_top || this.v_settings.v_dataheaderborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_bottom || this.v_settings.v_dataheaderborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_left || this.v_settings.v_dataheaderborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, ((Spartacus.Reporting.Field)this.v_fields[k]).v_border.v_right || this.v_settings.v_dataheaderborder.v_right);
                        }
                        else
                        {
                            v_cell.SetBorder(PDFjet.NET.Border.TOP, this.v_settings.v_dataheaderborder.v_top);
                            v_cell.SetBorder(PDFjet.NET.Border.BOTTOM, this.v_settings.v_dataheaderborder.v_bottom);
                            v_cell.SetBorder(PDFjet.NET.Border.LEFT, this.v_settings.v_dataheaderborder.v_left);
                            v_cell.SetBorder(PDFjet.NET.Border.RIGHT, this.v_settings.v_dataheaderborder.v_right);
                        }
                        v_row.Add(v_cell);
                    }
                }
                v_data.Add(v_row);
            }

            return v_data;
        }
        /// <summary>
        /// Renderiza matriz de dados.
        /// </summary>
        /// <returns>Matriz de dados.</returns>
        /// <param name="p_pageheight">Altura da página.</param>
        /// <param name="p_pagewidth">Largura da página.</param>
        /// <param name="p_datafieldfont">Fonte do campo de dados.</param>
        /// <param name="p_groupheaderfont">Fonte do cabeçalho de grupo.</param>
        /// <param name="p_groupfooterfont">Fonte do rodapé de grupo.</param>
        private System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> RenderData(
            float p_pageheight,
            float p_pagewidth,
            PDFjet.NET.Font p_datafieldfont,
            PDFjet.NET.Font p_groupheaderfont,
            PDFjet.NET.Font p_groupfooterfont
        )
        {
            System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>> v_data;
            System.Data.DataView v_view;
            string v_textrow;
            System.IO.StreamWriter v_writer;
            string v_text;
            int k, r, v_sectionrow;
            string v_sort;

            v_data = new System.Collections.Generic.List<System.Collections.Generic.List<PDFjet.NET.Cell>>();
            v_writer = new System.IO.StreamWriter(this.v_datafile);

            // se o relatorio possui grupos
            if (this.v_groups.Count > 0)
            {
                // ordenando campos da tabela original para otimizar a renderização
                v_sort = "";
                for (k = this.v_groups.Count - 1; k >= 0; k--)
                    v_sort += ((Spartacus.Reporting.Group)v_groups[k]).v_column + ", ";
                v_view = new System.Data.DataView(this.v_table);
                v_view.Sort = v_sort + ((Spartacus.Reporting.Group)v_groups[0]).v_sort;
                this.v_rendertable = v_view.ToTable();

                this.RenderGroup(
                    this.v_groups.Count - 1,
                    null,
                    null,
                    v_data,
                    p_pageheight,
                    p_pagewidth,
                    p_datafieldfont,
                    p_groupheaderfont,
                    p_groupfooterfont,
                    v_writer
                );
            }
            else // se o relatorio nao possui grupos
            {
                r = 0;
                foreach (System.Data.DataRow rb in this.v_table.Rows)
                {
                    for (v_sectionrow = 0; v_sectionrow < this.v_numrowsdetail; v_sectionrow++)
                    {
                        v_textrow = "";
                        for (k = 0; k < this.v_fields.Count; k++)
                        {
                            if (((Spartacus.Reporting.Field)this.v_fields[k]).v_row == v_sectionrow)
                            {
                                v_text = ((Spartacus.Reporting.Field)this.v_fields[k]).Format(rb[((Spartacus.Reporting.Field)this.v_fields[k]).v_column].ToString());
                                v_textrow += v_text.Replace(';', ',') + ";";
                            }
                        }
                        v_writer.WriteLine(v_textrow);
                    }

                    if (r % 2 == 0)
                        v_data.AddRange(this.v_detaileventemplate);
                    else
                        v_data.AddRange(this.v_detailoddtemplate);
                    r++;

                    this.v_perc += v_inc;
                    this.v_renderedrows++;
                    this.v_progress.FireEvent("Spartacus.Reporting.Report", "ExportPDF", this.v_perc, "Relatorio " + this.v_reportid.ToString() + ": linha " + this.v_renderedrows.ToString() + " de " + this.v_table.Rows.Count.ToString());
                }
            }

            v_writer.Flush();

            return v_data;
        }
Пример #8
0
        /// <summary>
        /// Converte a fonte em uma opção específica da PDFjet.
        /// </summary>
        /// <returns>Fonte conforme PDFjet.</returns>
        /// <param name="p_pdf">Objeto PDF.</param>
        public PDFjet.NET.Font GetFont(PDFjet.NET.PDF p_pdf)
        {
            PDFjet.NET.Font v_font = null;

            switch (this.v_family)
            {
                case Spartacus.Reporting.FontFamily.COURIER:
                    if (this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.COURIER_BOLD_OBLIQUE);
                        //this.v_nativefont = new System.Drawing.Font("Courier New", (float) this.v_size, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
                    }
                    if (this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.COURIER_BOLD);
                        //this.v_nativefont = new System.Drawing.Font("Courier New", (float) this.v_size, System.Drawing.FontStyle.Bold);
                    }
                    if (!this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.COURIER_OBLIQUE);
                        //this.v_nativefont = new System.Drawing.Font("Courier New", (float) this.v_size, System.Drawing.FontStyle.Italic);
                    }
                    if (!this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.COURIER);
                        //this.v_nativefont = new System.Drawing.Font("Courier New", (float) this.v_size, System.Drawing.FontStyle.Regular);
                    }
                    break;
                case Spartacus.Reporting.FontFamily.HELVETICA:
                    if (this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.HELVETICA_BOLD_OBLIQUE);
                        //this.v_nativefont = new System.Drawing.Font("Helvetica", (float) this.v_size, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
                    }
                    if (this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.HELVETICA_BOLD);
                        //this.v_nativefont = new System.Drawing.Font("Helvetica", (float) this.v_size, System.Drawing.FontStyle.Bold);
                    }
                    if (!this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.HELVETICA_OBLIQUE);
                        //this.v_nativefont = new System.Drawing.Font("Helvetica", (float) this.v_size, System.Drawing.FontStyle.Italic);
                    }
                    if (!this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.HELVETICA);
                        //this.v_nativefont = new System.Drawing.Font("Helvetica", (float) this.v_size, System.Drawing.FontStyle.Regular);
                    }
                    break;
                case Spartacus.Reporting.FontFamily.TIMES:
                    if (this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.TIMES_BOLD_ITALIC);
                        //this.v_nativefont = new System.Drawing.Font("Times New Roman", (float) this.v_size, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
                    }
                    if (this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.TIMES_BOLD);
                        //this.v_nativefont = new System.Drawing.Font("Times New Roman", (float) this.v_size, System.Drawing.FontStyle.Bold);
                    }
                    if (!this.v_bold && this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.TIMES_ITALIC);
                        //this.v_nativefont = new System.Drawing.Font("Times New Roman", (float) this.v_size, System.Drawing.FontStyle.Italic);
                    }
                    if (!this.v_bold && !this.v_italic)
                    {
                        v_font = new PDFjet.NET.Font(p_pdf, PDFjet.NET.CoreFont.TIMES_ROMAN);
                        //this.v_nativefont = new System.Drawing.Font("Times New Roman", (float) this.v_size, System.Drawing.FontStyle.Regular);
                    }
                    break;
                default:
                    break;
            }

            v_font.SetSize(this.v_size);

            return v_font;
        }
Пример #9
0
        /// <summary>
        /// Renderiza um rótulo de texto no Bloco.
        /// </summary>
        /// <param name="p_object">Objeto a ser renderizado.</param>
        /// <param name="p_posx">Posição X.</param>
        /// <param name="p_posy">Posição Y.</param>
        /// <param name="p_rightmargin">Margem direita.</param>
        /// <param name="p_font">Fonte.</param>
        /// <param name="p_pdf">Objeto PDF.</param>
        /// <param name="p_page">Página onde será renderizado.</param>
        private void RenderText(Spartacus.Reporting.Object p_object, double p_posx, double p_posy, double p_rightmargin, Spartacus.Reporting.Font p_font, PDFjet.NET.PDF p_pdf, PDFjet.NET.Page p_page)
        {
            PDFjet.NET.TextLine v_text;

            if (p_object.v_pdfobject == null)
            {
                v_text = new PDFjet.NET.TextLine(p_font.GetFont(p_pdf));

                v_text.SetText(System.Net.WebUtility.HtmlDecode(p_object.v_value));
                switch (p_object.v_align)
                {
                    case Spartacus.Reporting.FieldAlignment.LEFT:
                        v_text.SetPosition(p_posx + p_object.v_posx, p_posy + p_object.v_posy);
                        break;
                    case Spartacus.Reporting.FieldAlignment.RIGHT:
                        v_text.SetPosition(p_page.GetWidth() - p_rightmargin - v_text.GetWidth(), p_posy + p_object.v_posy);
                        break;
                    case Spartacus.Reporting.FieldAlignment.CENTER:
                        v_text.SetPosition(p_posx + ((p_page.GetWidth() - p_rightmargin - p_posx) / 2) - (v_text.GetWidth() / 2), p_posy + p_object.v_posy);
                        break;
                    default:
                        break;
                }

                v_text.DrawOn(p_page);

                p_object.v_pdfobject = v_text;
            }
            else
                ((PDFjet.NET.TextLine) p_object.v_pdfobject).DrawOn(p_page);
        }
Пример #10
0
        /// <summary>
        /// Renderiza uma imagem no Bloco.
        /// Essa imagem precisa vir de um arquivo em disco.
        /// </summary>
        /// <param name="p_object">Objeto a ser renderizado.</param>
        /// <param name="p_posx">Posição X.</param>
        /// <param name="p_posy">Posição Y.</param>
        /// <param name="p_rightmargin">Margem direita.</param>
        /// <param name="p_pdf">Objeto PDF.</param>
        /// <param name="p_page">Página onde o objeto será renderizado.</param>
        private void RenderImage(Spartacus.Reporting.Object p_object, double p_posx, double p_posy, double p_rightmargin, PDFjet.NET.PDF p_pdf, PDFjet.NET.Page p_page)
        {
            PDFjet.NET.Image v_image;
            System.IO.FileInfo v_info;
            char[] v_ch;
            string[] v_temp;
            Spartacus.Utils.Cryptor v_cryptor;
            string v_path;

            if (p_object.v_pdfobject == null)
            {
                v_ch = new char[1];
                v_ch [0] = '.';

                v_cryptor = new Spartacus.Utils.Cryptor("spartacus");
                try
                {
                    v_path = v_cryptor.Decrypt(p_object.v_value);
                }
                catch (System.Exception)
                {
                    v_path = p_object.v_value;
                }

                v_info = new System.IO.FileInfo(v_path);
                if (v_info.Exists)
                {
                    v_temp = v_path.Split(v_ch);
                    switch (v_temp[v_temp.Length - 1].ToUpper())
                    {
                        case "BMP":
                            v_image = new PDFjet.NET.Image(p_pdf, new System.IO.FileStream(v_path, System.IO.FileMode.Open, System.IO.FileAccess.Read), PDFjet.NET.ImageType.BMP);
                            break;
                        case "JPG":
                            v_image = new PDFjet.NET.Image(p_pdf, new System.IO.FileStream(v_path, System.IO.FileMode.Open, System.IO.FileAccess.Read), PDFjet.NET.ImageType.JPG);
                            break;
                        case "JPEG":
                            v_image = new PDFjet.NET.Image(p_pdf, new System.IO.FileStream(v_path, System.IO.FileMode.Open, System.IO.FileAccess.Read), PDFjet.NET.ImageType.JPG);
                            break;
                        case "PNG":
                            v_image = new PDFjet.NET.Image(p_pdf, new System.IO.FileStream(v_path, System.IO.FileMode.Open, System.IO.FileAccess.Read), PDFjet.NET.ImageType.PNG);
                            break;
                        case "JET":
                            v_image = new PDFjet.NET.Image(p_pdf, new System.IO.FileStream(v_path, System.IO.FileMode.Open, System.IO.FileAccess.Read), PDFjet.NET.ImageType.JET);
                            break;
                        default:
                            v_image = null;
                            break;
                    }

                    if (v_image != null)
                    {
                        switch (p_object.v_align)
                        {
                            case Spartacus.Reporting.FieldAlignment.LEFT:
                                v_image.SetPosition(p_posx + p_object.v_posx, p_posy + p_object.v_posy);
                                break;
                            case Spartacus.Reporting.FieldAlignment.RIGHT:
                                v_image.SetPosition(p_page.GetWidth() - p_rightmargin - v_image.GetWidth(), p_posy + p_object.v_posy);
                                break;
                            case Spartacus.Reporting.FieldAlignment.CENTER:
                                v_image.SetPosition(p_posx + ((p_page.GetWidth() - p_rightmargin - p_posx) / 2) - (v_image.GetWidth() / 2), p_posy + p_object.v_posy);
                                break;
                            default:
                                break;
                        }
                        v_image.DrawOn(p_page);

                        p_object.v_pdfobject = v_image;
                    }
                }
            }
            else
                ((PDFjet.NET.Image)p_object.v_pdfobject).DrawOn(p_page);
        }