Developer forum

Forum » Development » Missing Using in IronPdfRenderer

Missing Using in IronPdfRenderer

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We are experiencing issues with multiple IronCefSubprocess in the Task Explorer - please see this screen dump: https://app.screencast.com/wv3uNCFrtXznH, which is taken up CPU.

We believe that it is caused due to a missing "using" in the section of code in IronPdfRenderProvider:

public override byte[] RenderFromContent(PdfContent content, PdfRendererSettings settings)
        {
            IronPdfLicense.InstallLicense();
 
            var options = GetPdfPrintOptions(settings);
            options.MarginTop += content.HeaderHeight;
            options.MarginBottom += content.FooterHeight;
 
            var renderer = new ChromePdfRenderer
            {
                RenderingOptions = options
            };
 
            var doc = renderer.RenderHtmlAsPdf(content.ContentHtml);
 
            if (!string.IsNullOrEmpty(content.HeaderHtml))
            {
                var header = new HtmlHeaderFooter()
                {
                    MaxHeight = content.HeaderHeight,
                    HtmlFragment = content.HeaderHtml
                };
 
                doc.AddHtmlHeaders(header, 000);
            }
 
            if (!string.IsNullOrEmpty(content.FooterHtml))
            {
                var footer = new HtmlHeaderFooter()
                {
                    MaxHeight = content.FooterHeight,
                    HtmlFragment = content.FooterHtml
                };
 
                doc.AddHtmlFooters(footer, 000);
            }
 
            renderer.RenderingOptions = GetPdfPrintOptions(settings);
 
            if (!string.IsNullOrEmpty(content.FirstPageHtml))
            {
                var first = renderer.RenderHtmlAsPdf(content.FirstPageHtml);
                doc.PrependPdf(first);
            }
 
            if (!string.IsNullOrEmpty(content.LastPageHtml))
            {
                var last = renderer.RenderHtmlAsPdf(content.LastPageHtml);
                doc.AppendPdf(last);
            }
 
            var data = doc.BinaryData;
 
            return data;
        }

 

This part must be include in a using-statement to have the resources disposed:

var doc = renderer.RenderHtmlAsPdf(content.ContentHtml);

 

I hope it can be added in a hotfix to 9.15.x

 

Best regards, Anders

 

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Good find!

Devops#14442, made a pull request on it: https://dev.azure.com/dynamicwebsoftware/Dynamicweb/_git/Dynamicweb/pullrequest/9401

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Anders

DevOps#14442 regarding missing code in IronPdfRenderProvider
Now fixed in Dynamicweb version 9.15.10 

Sorry for any inconvenience this may have caused

Kind Regards
Dynamicweb Care Support
Kristian Kirkholt

 

You must be logged in to post in the forum