I've been working with the Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows NuGet package for conversion of HTML elements to PDF for the last week or so. I've ran into this error before, but I managed to get around it by not importing Syncfusion.Pdf in my classes and instead just importing Syncfusion.HtmlConverter.
This worked in one case on our client side application, but I'm running into it again when attempting to modify BlinkConverterSettings to change the formatting of the converted document on the server side which is a separate solution. In the code block below the PdfMargins constructor triggers the error saying that it exists in both Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable.
I only have ONE NuGet package installed relating to Syncfusion PDF documents. I do have Syncfusion.AspNet installed as well.
Is there a solution to this? I've seen a couple of other threads regarding the same issue but no resolution.
An example of the code I'm using:
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf.Graphics;
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings settings = new BlinkConverterSettings();
settings.Margin = new PdfMargins { Top = 40, Left = 30, Right = 30, Bottom = 40 }; // Error
htmlConverter.ConverterSettings = settings;
string baseUrl = @"C:/Users/***/Temp/"; // Can this not be a local directory?
var document = htmlConverter.Convert(htmlString, baseUrl);
var ms = new MemoryStream();
document.Save(ms);
document.Close(true);
Hi Kyle White
We have analyzed the reported issue “PdfMargins” exists in both Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable dlls. We suspect that you are installing both the NuGet packages (Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows and Syncfusion.Pdf.Aspnet) in your application. So that this assemblies conflict issue occurs. To overcome this problem, you can install the Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows package alone in your Net Core application. PdfMargins API is available in this package. We have attached a sample to converting Html to PDF document with the output document for your reference. Please try this in your end and let us know if it satisfies your requirement.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HtmlNet6.0343639557
Please refer to the below documentation,
UG: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/blink
Based on the platform our package will be varied. Since you have mentioned that you have been trying to convert the converting HTML to PDF, please find the assemblies required details from our UG documentation page.
Assemblies required : https://help.syncfusion.com/file-formats/pdf/nuget-packages-required#converting-html-to-pdf
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K
Thank you for the quick reply!
We did have the Syncfusion.AspNet NuGet package installed as well. Turns out it was one of those packages that my team had installed but not ever utilized, so removing it caused no errors and it solved my problem.
Thanks for pointing me in the right direction!
Hi Kyle
Thank you for your update. We are glad to hear that the reported issue is resolved.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Regards,
Gowthamraj K