Unable to use Converter class in DynamicPDF while generating the pdf from html.

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Re: Unable to use Converter class in DynamicPDF while generating the pdf from html.

DynamicPDF CoreSuite for .NET (v10) Forum

Hi Team,

we are using cete.dynamicpdf.coresuite.net(10.14.0.39242) package for the asp.net core application for printing and merging the PDFs and other documents. 
But unable to generate PDF .
 
Issue 1:  Unable to access the Converter class in application in spite of using the valid namespace.

Code:
string propertyDetailViewHTML5 = userService.PropertiesLogic().GetPropertyViewHtml(prop);
Converter.ConvertHtmlString(propertyDetailViewHTML5, @"D:\asdf.pdf");

Issue 2:    The following code generates PDF with the HTML tags 

                                     document.Pages.Add(page);                           
                                     page.Elements.Add(new Label(propertyDetailViewHTML5, 10, 10, 400, 800));
                                     document.Draw(@"D:\asdf.pdf");

Could you please suggest what needs to be done or changed in order to generate PDF from raw HTML & asp.net core View Page and how to merge PDFs.

Posted by a ceTe Software moderator
Hello,

Issue 1: You are getting this error because of accessing a namespace (Converter) which is not available in DynamicPDF Core Suite product. It is available in a separate and independent product called DynamicPDF Converter for .NET.  Please note that currently the DynamicPDF Converter for .NET does not supports .NET Core.

Issue 2:  The Label page element will add all the text as is to the PDF.  This is the reason why you are seeing HTML text is added along with tags. This is expected behavior.

If you would like to add HTML text to PDF using DynamicPDF Core Suite product then you will need to use HtmlArea page element. You can refer to the documentation on HtmlArea here. Also below is the code sample to use HTML string with HtmlArea page element.

            Document document = new Document();
            Page page = new Page();
            document.Pages.Add(page);
            string htmlText = "<html><body>This is to test</body></html>";
            HtmlArea area = new HtmlArea(htmlText, 0, 0, 500, 600);
            page.Elements.Add(area);
            string output = @"Path to save the output PDF";
            document.Draw(output);

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 10:11 AM.