public static string UpdateLetterHeaderHtml(string coveringLetterHtml, SummaryReportHeaderType reportHeaderType)
        {
            var newLetterheadHtml = string.Empty;
            switch (reportHeaderType)
            {
                case SummaryReportHeaderType.None:
                case SummaryReportHeaderType.GB:
                    newLetterheadHtml = NewLetterheadHtmlGB;
                    break;
                case SummaryReportHeaderType.ROI:
                    newLetterheadHtml = NewLetterheadHtmlROI;
                    break;
                case SummaryReportHeaderType.NI:
                    newLetterheadHtml = NewLetterheadHtmlNI;
                    break;
                default:
                    newLetterheadHtml = NewLetterheadHtmlGB;
                    break;
            }

            if (coveringLetterHtml == null)
            {
                return "";
            }
            oldleadingLineBreaksForVisitAddressHTML.ToList()
                .ForEach(x =>
                             {
                                 if (coveringLetterHtml.Contains(x))
                                 {
                                     coveringLetterHtml = coveringLetterHtml.Replace(x, "");
                                 }
                             });

            oldLetterheadsHTML
                .ToList()
                .ForEach(letterhead => coveringLetterHtml = coveringLetterHtml.Replace(letterhead, ""));

            if (coveringLetterHtml.Contains(newLetterheadHtml))
            {
                coveringLetterHtml = coveringLetterHtml.Replace(newLetterheadHtml, newLetterheadHtml + leadingLineBreakForVisitAddressHTML);
            }
            else
            {
                coveringLetterHtml = newLetterheadHtml + leadingLineBreakForVisitAddressHTML + coveringLetterHtml;
            }

            return coveringLetterHtml;
        }
Beispiel #2
0
    //public byte[] CreateComplianceReviewReport(string actionPlanHtml, string executiveSummaryHTML, string headerText, string contentPath, string clientLogoFilename)
    //{
    //    return CreateReport(actionPlanHtml, executiveSummaryHTML, headerText, contentPath, clientLogoFilename, true);
    //}
    //public byte[] CreateActionPlanReport(string actionPlanHtml, string headerText, string clientLogoFilename)
    //{
    //    return CreateReport(actionPlanHtml, "", headerText, "", clientLogoFilename, false);
    //}
    public byte[] CreateReport(string actionPlanHtml, string executiveSummaryHTML, string headerText, string contentPath, string clientLogoFilename, 
                                bool includeExecutiveSummary, SummaryReportHeaderType reportHeaderType)
    {
        var actionPlanPdf = CreateActionPlanPdf(actionPlanHtml, headerText, clientLogoFilename);

        if (includeExecutiveSummary)
        {
            var executiveSummaryPdf = CreateExecutiveSummaryPdf(executiveSummaryHTML, headerText, contentPath, reportHeaderType);

            //for each page in the letter add to the start on action plan pdf. Using this rather than append document because AppendDocument doesn't number the pages correctly.
            for (var pageIndex = 0; pageIndex < executiveSummaryPdf.Pages.Count; pageIndex++)
            {
                actionPlanPdf.Pages.Insert(pageIndex, executiveSummaryPdf.Pages[pageIndex]);
            }
        }

        return actionPlanPdf.Save();
    }
Beispiel #3
0
 public byte[] CreateSpecialReport(string executiveSummaryHTML, string headerText, string contentPath, SummaryReportHeaderType reportHeaderType)
 {
     //At a time special report just contain executive summary
     var executiveSummaryPdf = CreateExecutiveSummaryPdf(executiveSummaryHTML, headerText, contentPath, reportHeaderType);
     return executiveSummaryPdf.Save();
 }
Beispiel #4
0
    private Document CreateExecutiveSummaryPdf(string executiveSummaryHTML, string headerText, string contentPath, SummaryReportHeaderType reportHeaderType)
    {
        var pdfConvertorExecutiveSummary = new PdfConverter();

        pdfConvertorExecutiveSummary.PrepareRenderPdfPageEvent += pdfConvertorExecutiveSummary_PrepareRenderPdfPageEvent;
        pdfConvertorExecutiveSummary.LicenseKey = LICENSE_KEY;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.EmbedFonts = true;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.LeftMargin = 56;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.RightMargin = 30;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.TopMargin = 10;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.BottomMargin = 0;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.NoCompression;
        pdfConvertorExecutiveSummary.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;

        AddSummaryFooter(pdfConvertorExecutiveSummary, contentPath, reportHeaderType);

        if (string.IsNullOrEmpty(executiveSummaryHTML))
        {
            executiveSummaryHTML = "<html><body></body></html>";
        }
        var executiveSummaryPdf = pdfConvertorExecutiveSummary.GetPdfDocumentObjectFromHtmlString(executiveSummaryHTML);

        pdfConvertorExecutiveSummary.PrepareRenderPdfPageEvent -= pdfConvertorExecutiveSummary_PrepareRenderPdfPageEvent;

        return executiveSummaryPdf;
    }
Beispiel #5
0
    private void AddSummaryFooter(PdfConverter pdfConverter, string contentPath, SummaryReportHeaderType reportHeaderType)
    {
        //enable footer
        pdfConverter.PdfDocumentOptions.ShowFooter = true;
        pdfConverter.PdfFooterOptions.FooterHeight = 85;

        var url = "/templates/SummaryFooter.htm";

        if (reportHeaderType == SummaryReportHeaderType.NI)
        {
            url = "/templates/SummaryFooterNI.htm";
        }
        else if (reportHeaderType == SummaryReportHeaderType.ROI)
        {
           url = "/templates/SummaryFooterROI.htm";
        }

        //write the footer
        var summaryFooterUrl = contentPath + url;
        var footerHtml = new HtmlToPdfElement(0, 5, 0, pdfConverter.PdfFooterOptions.FooterHeight, summaryFooterUrl, 1024, 0);

        footerHtml.FitHeight = true;
        pdfConverter.PdfFooterOptions.AddElement(footerHtml);
    }