Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Apr 21, 2015 8:58 am

When I run my app on a local machine and create pdf file everything looks ok, but when I push app to azure grid is all messed up. All other parts of pdf except grid are the same. You can see example from the attachment.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Tue Apr 21, 2015 1:34 pm

I am currently using Free Spire.PDF for .NET.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Wed Apr 22, 2015 3:42 am

Hello,

Thanks for your inquiry.
Please download the commercial version (Spire.PDF Pack(Hot Fix) Version:3.2.178 ) via link below and have a try:
http://www.e-iceblue.com/Download/downl ... t-now.html
If there are any questions, welcome to get it back to us.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Wed Apr 22, 2015 12:39 pm

Are there any instructions how to apply this fix? I installed my Free Spire.PDF through Nuget package manager.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Thu Apr 23, 2015 6:14 am

Hello,

Please first remove the old dll. Then, add new dll as reference in Bin folder of the commercial version downloaded thought the below path: "..\Spire.PDF\Bin\NET4.0\ ".
If there are any questions, welcome to get it back to us.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Thu Apr 23, 2015 7:59 am

So first I should delete Free Spire.PDF.

Second install commercial version downloaded from that path. Relative path from where?

Third remove old dll from installed commerical version bin folder and copy dll from hotfix.

?

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Thu Apr 23, 2015 9:41 am

Hello,

Please follow the picture from 001.png to 003.png to finish operation.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Apr 24, 2015 5:17 am

Hello,

Has your issue been resolved? Thanks for your feedback.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Apr 24, 2015 9:02 am

Unfortunately no. On Azure grid is still messed up and now I even got some red evaluation message on top of the document.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Mon Apr 27, 2015 2:29 am

Hello,

Thanks for your feedback.
Sorry to hear that. Could you please offer the generated file? Please package your file into ZIP file format. Then, upload your zip file. And could you please share the code with us? It would be helpful to replicate the issue and work out the solution for you ASAP.

Thanks,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Apr 27, 2015 4:19 pm

Below are all methods that I use for generating report. In the attachment you can see how same report looks like on azure (report_azure.pdf) and my local machine (report_local.pdf).

Code: Select all

private void SetDocumentTemplate(PdfDocument doc, string headerText)
{
     SizeF pageSize = PdfPageSize.A4;

     //margin
     PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
     PdfMargins margin = new PdfMargins();
     margin.Top = unitCvtr.ConvertUnits(1f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
     margin.Bottom = unitCvtr.ConvertUnits(2f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
     margin.Left = unitCvtr.ConvertUnits(0f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
     margin.Right = margin.Left;

     PdfPageTemplateElement leftSpace = new PdfPageTemplateElement(margin.Left, pageSize.Height);
     doc.Template.Left = leftSpace;

     PdfPageTemplateElement rightSpace = new PdfPageTemplateElement(margin.Right, pageSize.Height);
     doc.Template.Right = rightSpace;

     PdfPageTemplateElement topSpace = new PdfPageTemplateElement(pageSize.Width, margin.Top);
     topSpace.Foreground = true;
     doc.Template.Top = topSpace;

     //draw header
     PdfFont headerFont = new PdfFont(PdfFontFamily.Helvetica, 6f);
     PdfSolidBrush headerBrush = new PdfSolidBrush(new PdfRGBColor(56, 62, 75));
     PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Right);

     topSpace.Graphics.SetTransparency(0.5f);
     topSpace.Graphics.DrawString(headerText, headerFont, headerBrush, topSpace.Graphics.ClientSize.Width, 0, format);

     PdfPageTemplateElement bottomSpace = new PdfPageTemplateElement(pageSize.Width, margin.Bottom);
     bottomSpace.Foreground = true;
     doc.Template.Bottom = bottomSpace;

     // draw footer
     PdfImage footerImage = PdfImage.FromFile(System.Web.HttpContext.Current.Server.MapPath("~/Content/images/logo.png"));

     float y = bottomSpace.Graphics.ClientSize.Height - footerImage.PhysicalDimension.Height;
     PointF footerLocation = new PointF((bottomSpace.Graphics.ClientSize.Width - footerImage.PhysicalDimension.Width) / 2, y);

     bottomSpace.Graphics.SetTransparency(0.5f);
     bottomSpace.Graphics.DrawImage(footerImage, footerLocation);

     PdfFont footerFont = new PdfFont(PdfFontFamily.Helvetica, 6f);
     PdfSolidBrush footerBrush = new PdfSolidBrush(new PdfRGBColor(56, 62, 75));
     PdfStringFormat centerAlignment = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
     bottomSpace.Graphics.DrawString("Powered By", footerFont, footerBrush, bottomSpace.Graphics.ClientSize.Width / 2, y,   centerAlignment);

     // draw page number label in footer
     PdfPageNumberField pageNumber = new PdfPageNumberField();
     PdfPageCountField pageCount = new PdfPageCountField();
     PdfCompositeField pageNumberLabel = new PdfCompositeField();
     pageNumberLabel.AutomaticFields = new PdfAutomaticField[] { pageNumber, pageCount };
     pageNumberLabel.Brush = new PdfSolidBrush(new PdfRGBColor(134, 132, 142)); ;
     pageNumberLabel.Font = footerFont;
     pageNumberLabel.StringFormat = format;
     pageNumberLabel.Text = "{0} of {1}";
     pageNumberLabel.Draw(bottomSpace.Graphics, bottomSpace.Graphics.ClientSize.Width - 79, bottomSpace.Graphics.ClientSize.Height - footerFont.Height);
}


private string CreatePdfReport(UserCompensationReport userReport, int agencyId, string agencyName, PayStub payStub, string clientName)
{
      //Create a pdf document.
      PdfDocument doc = new PdfDocument();

      //set document info
      doc.DocumentInformation.Author = clientName;
      doc.DocumentInformation.Creator = clientName;
      doc.DocumentInformation.Keywords = "pdf, performology, pay stub, " + agencyName + ", " + userReport.UserFullName + ", " + userReport.PayDate;
      doc.DocumentInformation.Producer = "Performology";
      doc.DocumentInformation.Subject = "Performology Pay Stub";
      doc.DocumentInformation.Title = "Pay Stub - " + userReport.UserFullName + " - " + userReport.PayDate;

      string headerText = LocalizedDateTime.ConvertServerDateTimetoLocalized(payStub.GeneratedTime).ToString("MM/dd/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
      PayStub replacedPayStub = payStub.PayStub1.FirstOrDefault();
      if (replacedPayStub != null)
           headerText += " (Replacement for " + LocalizedDateTime.ConvertServerDateTimetoLocalized(replacedPayStub.GeneratedTime).ToString("MM/dd/yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture) + ")";

      SetDocumentTemplate(doc, headerText);

      float y = 0;

      // Create first page. This method also sets footer
      PdfPageBase page = doc.Pages.Add();
      y = 0;

      PdfStringFormat leftAlignment = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
      PdfStringFormat leftAlignmentVerticalTop = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
      PdfStringFormat rightAlignment = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
      PdfStringFormat centerAlignment = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
      PdfStringFormat centerAlignmentVerticalTop = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);

      PdfFont largestFont = new PdfFont(PdfFontFamily.Helvetica, 20f, PdfFontStyle.Bold);
      PdfFont largerFont = new PdfFont(PdfFontFamily.Helvetica, 18f);
      PdfFont largerFontBold = new PdfFont(PdfFontFamily.Helvetica, 18f, PdfFontStyle.Bold);
      PdfFont normalFont = new PdfFont(PdfFontFamily.Helvetica, 16f);
      PdfFont smallFontItalic = new PdfFont(PdfFontFamily.Helvetica, 10f, PdfFontStyle.Italic);
      PdfFont normalFontBold = new PdfFont(PdfFontFamily.Helvetica, 16f, PdfFontStyle.Bold);
      PdfFont normalFontBoldUnderline = new PdfFont(PdfFontFamily.Helvetica, 16f, PdfFontStyle.Underline | PdfFontStyle.Bold);

      PdfRGBColor gray = new PdfRGBColor(56, 62, 75);
      PdfSolidBrush brush = new PdfSolidBrush(gray);
      PdfSolidBrush blackBrush = new PdfSolidBrush(Color.Black);

      // draw agency name, user name and pay date

      SizeF size = largerFontBold.MeasureString(agencyName, page.Canvas.ClientSize.Width);
      page.Canvas.DrawString(agencyName, largerFontBold, blackBrush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

      y += size.Height + 10;

      string text = "Compensation Statement for " + userReport.PayDate;
      size = normalFont.MeasureString(text, page.Canvas.ClientSize.Width);
      page.Canvas.DrawString(text, normalFont, blackBrush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

      y += size.Height + 10;

      text = "Name: " + userReport.UserFullName;
      size = normalFont.MeasureString(text, page.Canvas.ClientSize.Width);
      page.Canvas.DrawString(text, normalFont, blackBrush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

      y += size.Height + 50;

      PdfPen pen = new PdfPen(Color.Black, 1f);
      PdfPen penGray = new PdfPen(gray, 1f);
      PdfSolidBrush frequencyBrush = new PdfSolidBrush(new PdfRGBColor(233, 233, 233));
      PdfSolidBrush periodBrush = new PdfSolidBrush(new PdfRGBColor(88, 170, 206));
      float width1 = (page.Canvas.ClientSize.Width - 50 - 30) / 3 * 2;
      float width2 = (page.Canvas.ClientSize.Width - 50 - 30) / 3;
      RectangleF rctg;

      foreach (FrequencyCompensationReport frequencyReport in userReport.FrequenciesReports)
      {
           if (y + 30 > page.Canvas.ClientSize.Height)
           {
                page = doc.Pages.Add();
                y = 0;
           }

           // draw reports for every frequency
           rctg = new RectangleF(0, y, page.Canvas.ClientSize.Width, 30);
           page.Canvas.DrawRectangle(pen, frequencyBrush, rctg);
           page.Canvas.DrawString(frequencyReport.FrequencyName + " Compensation -- $" + frequencyReport.FrequencyTotal.ToString("#,##0.00"), largerFont, blackBrush, rctg, centerAlignment);

           y += 60;

           foreach (FrequencyPeriodCompensationReport periodReport in frequencyReport.Periods)
           {
                text = frequencyReport.FrequencyPeriod + ": " + periodReport.StartDate + "-" + periodReport.EndDate;
                size = normalFontBoldUnderline.MeasureString(text, page.Canvas.ClientSize.Width - 20, leftAlignmentVerticalTop);

                if (y + size.Height > page.Canvas.ClientSize.Height)
                {
                     page = doc.Pages.Add();
                     y = 0;
                }

                // draw reports for every period
                page.Canvas.DrawString(text, normalFontBoldUnderline, periodBrush, 20, y, leftAlignmentVerticalTop);

                y += 30;

                foreach (CompensationComponentCalculationsData componentReport in periodReport.Components)
                {
                        size = normalFont.MeasureString(componentReport.Name, width1);
                        text = "$" + componentReport.TotalAmount.ToString("#,##0.00");
                        SizeF size2 = normalFont.MeasureString(text, width2, rightAlignment);

                        if (y + Math.Max(size.Height, size2.Height) > page.Canvas.ClientSize.Height)
                        {
                            page = doc.Pages.Add();
                            y = 0;
                        }

                        // draw reports for every component

                        rctg = new RectangleF(50, y, width1, size.Height);
                        page.Canvas.DrawRectangle(new PdfSolidBrush(Color.White), rctg);
                        page.Canvas.DrawString(componentReport.Name, normalFont, brush, rctg, leftAlignment);

                        rctg = new RectangleF(width1 + 50, y, width2, size2.Height);
                        page.Canvas.DrawRectangle(new PdfSolidBrush(Color.White), rctg);
                        page.Canvas.DrawString(text, normalFont, brush, rctg, rightAlignment);

                        y += size.Height + 20;
                    }

                    y -= 10;

                    if (y + 5 > page.Canvas.ClientSize.Height)
                    {
                        page = doc.Pages.Add();
                        y = 0;
                    }

                    page.Canvas.DrawLine(penGray, 40, y, page.Canvas.ClientSize.Width - 20, y);

                    y = y + 10;

                    size = normalFont.MeasureString("Sub-Total", width1);
                    string subTotal = "$" + periodReport.FrequencyPeriodTotal.ToString("#,##0.00");
                    SizeF size3 = normalFont.MeasureString(subTotal, width2, rightAlignment);

                    if (y + Math.Max(size.Height, size3.Height) > page.Canvas.ClientSize.Height)
                    {
                        page = doc.Pages.Add();
                        y = 0;
                    }


                    rctg = new RectangleF(50, y, width1, size.Height);
                    page.Canvas.DrawRectangle(new PdfSolidBrush(Color.White), rctg);
                    page.Canvas.DrawString("Sub-Total", normalFont, brush, rctg, leftAlignment);


                    rctg = new RectangleF(width1 + 50, y, width2, size3.Height);
                    page.Canvas.DrawRectangle(new PdfSolidBrush(Color.White), rctg);
                    page.Canvas.DrawString(subTotal, normalFont, brush, rctg, rightAlignment);

                    y += 60;
           }
       }

       if (payStub.ManualAdjustmentAmount != null)
       {
                decimal adjustment = (decimal)payStub.ManualAdjustmentAmount;
                userReport.Total += adjustment;

                if (payStub.ManualAdjustmentDescription != null)
                    text = payStub.ManualAdjustmentDescription;
                else
                    text = "Manual Adjustment";

                size = largerFont.MeasureString(text, page.Canvas.ClientSize.Width, centerAlignment);
                if (size.Height < 30)
                    size.Height = 30;

                if (y + size.Height > page.Canvas.ClientSize.Height)
                {
                    page = doc.Pages.Add();
                    y = 0;
                }

                rctg = new RectangleF(0, y, page.Canvas.ClientSize.Width, size.Height);
                page.Canvas.DrawRectangle(pen, frequencyBrush, rctg);
                page.Canvas.DrawString(text, largerFont, blackBrush, rctg, centerAlignment);

                y += 60;

                text = "$" + adjustment.ToString("#,##0.00");
                size = normalFont.MeasureString(text, page.Canvas.ClientSize.Width, centerAlignment);

                if (y + size.Height > page.Canvas.ClientSize.Height)
                {
                    page = doc.Pages.Add();
                    y = 0;
                }

                page.Canvas.DrawString(text, normalFont, brush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

                y += 60;
       }

       y += 30;

       if (y + 10 > page.Canvas.ClientSize.Height)
       {
                page = doc.Pages.Add();
                y = 0;
       }

       page.Canvas.DrawLine(new PdfPen(gray, 4f), 0, y, page.Canvas.ClientSize.Width, y);

       y += 50;

       //text = "$" + userReport.Total.ToString("#,##0.00");
       text = "Grand Total $" + userReport.Total.ToString("#,##0.00");
       size = largestFont.MeasureString(text, page.Canvas.ClientSize.Width, centerAlignment);

       if (y + size.Height > page.Canvas.ClientSize.Height)
       {
             page = doc.Pages.Add();
             y = 0;
       }

       page.Canvas.DrawString(text, largestFont, brush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

       // draw details for every compensation component

       foreach (FrequencyCompensationReport frequencyReport in userReport.FrequenciesReports)
       {
                // page break for every frequency
                page = doc.Pages.Add();
                y = 0;

                page.Canvas.DrawString(frequencyReport.FrequencyName + " Compensation", largestFont, blackBrush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);

                foreach (FrequencyPeriodCompensationReport periodReport in frequencyReport.Periods)
                {
                    y += 50;

                    text = frequencyReport.FrequencyPeriod + ": " + periodReport.StartDate + "-" + periodReport.EndDate;
                    size = normalFontBoldUnderline.MeasureString(text, page.Canvas.ClientSize.Width, leftAlignmentVerticalTop);

                    if (y + size.Height > page.Canvas.ClientSize.Height)
                    {
                        page = doc.Pages.Add();
                        y = 0;
                    }

                    // draw reports for every period
                    page.Canvas.DrawString(text, normalFontBoldUnderline, periodBrush, 0, y, leftAlignmentVerticalTop);

                    foreach (CompensationComponentCalculationsData componentReport in periodReport.Components)
                    {
                        y += 40;

                        size = normalFont.MeasureString(componentReport.Name, page.Canvas.ClientSize.Width, centerAlignmentVerticalTop);

                        if (y + size.Height > page.Canvas.ClientSize.Height)
                        {
                            page = doc.Pages.Add();
                            y = 0;
                        }

                        // draw component name
                        page.Canvas.DrawString(componentReport.Name, normalFont, brush, page.Canvas.ClientSize.Width / 2, y, centerAlignmentVerticalTop);
                        y += 30;

                        bool hasRecords = false;

                        if (componentReport.CompensationElementData != null)
                        {
                            if (componentReport.CompensationElementData.Records != null && componentReport.CompensationElementData.Records.Count > 0)
                            {
                                string elementDateTypeColumnName = db.AttributeDateTypes.FirstOrDefault(i => i.AttributeId == componentReport.CompensationElementData.AttributeId && i.DateTypeId == componentReport.DateTypeId).Name;

                                PdfGrid grid = GenerateTable(componentReport.CompensationElementData.Records, elementDateTypeColumnName, componentReport.DateType, "Records Eligible for Compensation", page.Canvas.ClientSize.Width);

                                PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
                                gridLayout.Break = PdfLayoutBreakType.FitElement;

                                PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);

                                page = result.Page;
                                y = result.Bounds.Bottom;
                                hasRecords = true;
                            }

                            if (componentReport.CompensationElementData.ChargebackRecords != null && componentReport.CompensationElementData.ChargebackRecords.Count > 0)
                            {
                                if (hasRecords)
                                    y += 25;

                                string chargebackDateTypeColumnName = db.AttributeDateTypes.FirstOrDefault(i => i.AttributeId == componentReport.ChargebackAttributeId && i.DateTypeId == componentReport.ChargebackDateTypeId).Name;

                                PdfGrid grid = GenerateTable(componentReport.CompensationElementData.ChargebackRecords, chargebackDateTypeColumnName, componentReport.ChargebackDateType, "Chargeback Records", page.Canvas.ClientSize.Width);

                                PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
                                gridLayout.Break = PdfLayoutBreakType.FitElement;

                                PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);

                                page = result.Page;
                                y = result.Bounds.Bottom;
                                hasRecords = true;
                            }
                        }

                        if (componentReport.IsBasisDifferent)
                        {
                            if (componentReport.CompensationBasisData.Records != null && componentReport.CompensationBasisData.Records.Count > 0)
                            {
                                if (hasRecords)
                                    y += 25;

                                string basisDateTypeColumnName = db.AttributeDateTypes.FirstOrDefault(i => i.AttributeId == componentReport.CompensationBasisData.AttributeId && i.DateTypeId == componentReport.DateTypeId).Name;

                                PdfGrid grid = GenerateTable(componentReport.CompensationBasisData.Records, basisDateTypeColumnName, componentReport.DateType, "Qualifying Records", page.Canvas.ClientSize.Width);

                                PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
                                gridLayout.Break = PdfLayoutBreakType.FitElement;

                                PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);

                                page = result.Page;
                                y = result.Bounds.Bottom;
                                hasRecords = true;
                            }

                            if (componentReport.CompensationBasisData.ChargebackRecords != null && componentReport.CompensationBasisData.ChargebackRecords.Count > 0)
                            {
                                if (hasRecords)
                                    y += 25;

                                string chargebackDateTypeColumnName = db.AttributeDateTypes.FirstOrDefault(i => i.AttributeId == componentReport.ChargebackAttributeId && i.DateTypeId == componentReport.ChargebackDateTypeId).Name;

                                PdfGrid grid = GenerateTable(componentReport.CompensationBasisData.ChargebackRecords, chargebackDateTypeColumnName, componentReport.ChargebackDateType, "Chargeback Records", page.Canvas.ClientSize.Width);

                                PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
                                gridLayout.Break = PdfLayoutBreakType.FitElement;

                                PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);

                                page = result.Page;
                                y = result.Bounds.Bottom;
                                hasRecords = true;
                            }
                        }

                        if (!hasRecords)
                        {
                            size = smallFontItalic.MeasureString("No records for this component.", page.Canvas.ClientSize.Width, leftAlignmentVerticalTop);

                            if (y + size.Height > page.Canvas.ClientSize.Height)
                            {
                                page = doc.Pages.Add();
                                y = 0;
                            }

                            page.Canvas.DrawString("No records for this component.", smallFontItalic, brush, 20, y, leftAlignmentVerticalTop);
                        }
                    }
                }
       }

       string payDate = userReport.PayDate.Replace("/", "-");
       string fileName = userReport.UserFullName.Replace(" ", "_") + payDate + GetPayStubHash(userReport.UserId, payDate) + ".pdf";
       //string fileName = "test.pdf";
       string path = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/" + fileName);
       //Save doc file.
       doc.SaveToFile(path);
       doc.Close();

       //Launching the Pdf file.
       //System.Diagnostics.Process.Start(path);
       return path;
}



private PdfGrid GenerateTable(List<RecordsReport> records, string dateTypeColumnName, string dateType, string tableHeading, float pageWidth)
{
            PdfGrid grid = new PdfGrid();

            PdfBorders border = new PdfBorders();
            border.All = new PdfPen(new PdfRGBColor(217, 217, 217), 0.7f);

            //grid.RepeatHeader = true;
            grid.Style.CellPadding = new PdfPaddings(1, 1, 1, 1);

            PdfStringFormat centerFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
            PdfStringFormat leftFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
            PdfStringFormat rightFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
            PdfTrueTypeFont firstHeaderRowFont = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Italic));
            PdfTrueTypeFont secondHeaderRowFont = new PdfTrueTypeFont(new Font("Arial", 7f, FontStyle.Bold));
            PdfTrueTypeFont bodyRowFont = new PdfTrueTypeFont(new Font("Arial", 6f));
            PdfSolidBrush grayBrush = new PdfSolidBrush(new PdfRGBColor(217, 217, 217));
            PdfSolidBrush yellowBrush = new PdfSolidBrush(new PdfRGBColor(255, 255, 204));

            string [][] dataSource = GetDataSource(records, dateTypeColumnName, dateType);

            string[] header = dataSource[0];
            grid.Columns.Add(header.Length);

            grid.Columns[0].Width = pageWidth * 0.04f;
            grid.Columns[1].Width = pageWidth * 0.07f;
            grid.Columns[2].Width = pageWidth * 0.13f;
            grid.Columns[3].Width = pageWidth * 0.09f;
            grid.Columns[4].Width = pageWidth * 0.09f;
            grid.Columns[5].Width = pageWidth * 0.05f;
            grid.Columns[6].Width = pageWidth * 0.08f;
            grid.Columns[7].Width = pageWidth * 0.05f;
            grid.Columns[8].Width = pageWidth * 0.13f;
            grid.Columns[9].Width = pageWidth * 0.09f;
            grid.Columns[10].Width = pageWidth * 0.09f;
            grid.Columns[11].Width = pageWidth * 0.09f;

            grid.Columns[0].Format = centerFormat;
            grid.Columns[1].Format = centerFormat;
            grid.Columns[2].Format = leftFormat;
            grid.Columns[3].Format = leftFormat;
            grid.Columns[4].Format = leftFormat;
            grid.Columns[5].Format = rightFormat;
            grid.Columns[6].Format = rightFormat;
            grid.Columns[7].Format = rightFormat;
            grid.Columns[8].Format = leftFormat;
            grid.Columns[9].Format = leftFormat;
            grid.Columns[10].Format = leftFormat;
            grid.Columns[11].Format = leftFormat;

            PdfGridRow headerRow = grid.Headers.Add(1)[0];

            headerRow.Height = 15;
            headerRow.Cells[0].Value = tableHeading;
            headerRow.Cells[0].Style.Borders = border;
            headerRow.Cells[0].StringFormat = centerFormat;
            headerRow.Cells[0].Style.Font = firstHeaderRowFont;
            headerRow.Cells[0].ColumnSpan = grid.Columns.Count;
            headerRow.Cells[0].Style.BackgroundBrush = grayBrush;

            PdfGridRow headerRow2 = grid.Headers.Add(1)[1];

            for (int i = 0; i < header.Length; i++)
            {
                headerRow2.Cells[i].Value = header[i];
                headerRow2.Cells[i].StringFormat = centerFormat;
                headerRow2.Cells[i].Style.Borders = border;
                headerRow2.Cells[i].Style.Font = secondHeaderRowFont;
                headerRow2.Cells[i].Style.Borders = border;
                headerRow2.Cells[i].Style.BackgroundBrush = yellowBrush;
            }

            for (int i = 1; i < dataSource.Length; i++)
            {
                PdfGridRow row = grid.Rows.Add();
                row.Style.Font = bodyRowFont;
                if(i == dataSource.Length - 1)
                    row.Style.BackgroundBrush = yellowBrush;

                string[] rowData = dataSource[i];
                for (int j = 0; j < rowData.Length; j++) {
                    row.Cells[j].Value = rowData[j];
                    row.Cells[j].Style.Borders = border;
                }
            }

            return grid;
}



private string[][] GetDataSource(List<RecordsReport> records, string dateTypeColumnName, string dateType)
{
            string[][] datasource = new string[records.Count + 2][];

            datasource[0] = new string[] { "No", dateTypeColumnName, "Customer Name", "Policy Type", "Company", "Items", "Premium", "Points", "Source", "Producer", "Team", "Location" };

            int totalItems = 0, totalPoints = 0;
            decimal totalPremium = 0;

            for (int i = 0; i < records.Count; i++)
            {
                string date = "";
                switch (dateType)
                {
                    case "Verification Date":
                        date = records[i].issuedDate;
                        break;
                    case "Activity Date":
                        date = records[i].saleDate;
                        break;
                    case "Effective Date":
                        date = records[i].effectiveDate;
                        break;
                }

                datasource[i + 1] = new string[] { (i + 1).ToString(), date, records[i].customer, records[i].policyType, records[i].company, records[i].items.ToString(), (records[i].premium ?? 0).ToString("$#,##0.00"), records[i].points.ToString(), records[i].leadSource, records[i].producer, records[i].team, records[i].location };

                totalItems += records[i].items ?? 0;
                totalPoints += records[i].points ?? 0;
                totalPremium += records[i].premium ?? 0;
            }

            datasource[datasource.Count() - 1] = new string[] { "", "", "", "", "TOTALS", totalItems.ToString(), totalPremium.ToString("$#,##0.00"), totalPoints.ToString(), "", "", "", "" };

            return datasource;
}




Thanks.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Tue Apr 28, 2015 6:39 am

Hello,

Thanks for your information.
We checked your documents and all fonts used in them are standard font.
Please check weather the same fonts are installed on your Azure. If not, please install them and try again.
If there are any questions, welcome to get it back to us.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Apr 28, 2015 11:50 am

Yes it seems that problem was caused by fonts. Since it's not important for me to use those fonts for grid, instead of installing them on Azure, I just used same fonts as for the rest of the report and everything is fine now.

So instead of:

Code: Select all

PdfTrueTypeFont firstHeaderRowFont = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold));
PdfTrueTypeFont secondHeaderRowFont = new PdfTrueTypeFont(new Font("Arial", 7f, FontStyle.Bold));
PdfTrueTypeFont bodyRowFont = new PdfTrueTypeFont(new Font("Arial", 6f));



I use

Code: Select all

PdfFont firstHeaderRowFont = new PdfFont(PdfFontFamily.Helvetica, 10f, PdfFontStyle.Bold);
PdfFont secondHeaderRowFont = new PdfFont(PdfFontFamily.Helvetica, 7f, PdfFontStyle.Bold);
PdfFont bodyRowFont = new PdfFont(PdfFontFamily.Helvetica, 6f);



Also to remove that red evaluation message I just reinstalled Free Spire.PDF.

Thanks a lot for Your help.

jbojcic
 
Posts: 23
Joined: Mon Apr 13, 2015 3:03 pm

Wed Apr 29, 2015 2:08 am

Hello,

Thanks for your feedback.
I am glad to hear your issue is resolved.
In my previous email, the version I have gaven to you is the Commercial Edition. You can contact our sales team(sales@e-iceblue.com) to get a temporary license file to remove the warning message and have a better evalution on our products.
Please feel free to contact us, if you have any questions or needs. We are here for help.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Return to Spire.PDF