Cannot set margin bottom to 0px

Hi, i am trying to convert an html page composed only with svg graphics to a pdf documetn using the Blink Binaries. 

I am trying to set the margins to 0

BlinkConverterSettings converterSettings = new BlinkConverterSettings();converterSettings.Margin = new Syncfusion.Pdf.Graphics.PdfMargins { Top = 0, Bottom = 0, Left = 0, Right = 0 };

Once the document is created seems that only the top margin is respected 


Top and left

Bottom



I am using the latest version of blink binaries : 

Version 19.4.0.55

11 Replies

GK Gowthamraj Kumar Syncfusion Team March 15, 2022 12:01 PM UTC

Hi Stefano, 
 
We have tried to reproduce the reported issue with the provided details, but it is working properly. SVG to PDF conversion will preserve the PDF document like how the input SVG file is rendered in web browsers. We have created a sample to convert the test SVG file to a PDF document using blink rendering engine. We internally make use of chromium executables for converting HTML SVG to PDF. It preserves the output PDF document like how the input HTML/SVG file/URL is displayed on the web browsers (chrome). We have attached the sample with output document (with and without margin) for your reference. We were unable to reproduce the issue. Kindly please try the below sample in your end and let us know the result.       
 
 
Please refer to the below documentation for more information, 
 
Note: By default, when converting Html to PDF document, the margin is zero in all sides of the PDF document.  
 
If still you are facing the same issue, kindly provide more details such as complete SVG file, complete code snippet, output document, modified sample to reproduce the issue in our end. So, that it will be helpful for us to analyze and provide you the solution at the earliest.       
 
Regards, 
Gowtham raj K 



ST Stefano March 18, 2022 07:11 PM UTC

I am sorry, probably i did not explained correctly the behavior.
I have an html page with svg graphic inside and i'd like to have a pdf output with no margin.
I've modified your code to use a sample html document and set the margins to 0 and when the page changes this is the behavior 



Attachment: WpfApp1_81f7c5f2.zip


GK Gowthamraj Kumar Syncfusion Team March 21, 2022 01:36 PM UTC

Hi Stefano, 
 
We were able to reproduce the reported issue with provided sample on our end. Currently, we are validating on this and we will update the further details on March 23rd 2022.  
Meanwhile, please confirm us whether the reported issue is the below red highlighted content (Slightly margins space at bottom) ? 
 
 
Regards, 
Gowthamraj K 



ST Stefano March 21, 2022 05:40 PM UTC

Yes, the issue i've reported is wright that slight margin.


Thanks Stefano



GK Gowthamraj Kumar Syncfusion Team March 23, 2022 11:45 AM UTC

Hi Stefano, 
 
On our further analysis, the reported slight margin space issue on bottom of the page while converting Html to PDF in Blink rendering engine, will be resolved by using scale property. We can set the value of the scale property to avoid the space in bottom margin. We internally make use of chromium executable in headless mode for converting HTML to PDF using Blink rendering engine. The converter will preserve the output PDF document, like how the input HTML file/URL is displayed in chromium-based web browsers. The same behavior as replicates in our converter. We have attached the output document and screenshot of chrome print preview for your reference. 
 
 
Please find the code snippet below to use scale property, 
 
//Initialize HTML to PDF converter with Blink rendering engine 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink); 
 
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); 
 
blinkConverterSettings.Margin = new Syncfusion.Pdf.Graphics.PdfMargins { Top = 0, Bottom = 0, Left = 0, Right = 0 }; 
 
//Set the BlinkBinaries folder path 
 
blinkConverterSettings.BlinkPath = @"\BlinkBinaries\"; 
 
blinkConverterSettings.Scale = 1.0f; 
 
//Assign Blink converter settings to HTML converter 
htmlConverter.ConverterSettings = blinkConverterSettings; 
 
string html = System.IO.Path.GetFullPath(@"../../full.html"); 
 
//Convert URL to PDF 
PdfDocument document = htmlConverter.Convert(html); 
 
//Save and close the PDF document  
document.Save("../../BlinkOutput.pdf"); 
 
document.Close(true); 
 
Kindly try the provided solution on your end and let us know the result. 
 
Regards, 
Gowthamraj K 



ST Stefano March 24, 2022 11:57 AM UTC

Hi  Gowthamraj.
From your file i see that the margin is sligheter than before but still present in the document.
By the way i am using WPF and i do not have any Scale property on BlinkSettings model



Stefano



GK Gowthamraj Kumar Syncfusion Team March 25, 2022 10:19 AM UTC

Hi Stefano, 

From your file i see that the margin is sligheter than before but still present in the document. 
As we said earlier, we internally make use of chromium executable in headless mode for converting HTML to PDF using Blink rendering engine. The converter will preserve the output PDF document, like how the input HTML file/URL is displayed in chromium-based web browsers. You can check the same behavior with Chrome print preview, both the output are same. The same behavior as replicates in our converter. We have attached the chrome output document for your reference,  

Please find the below output screenshot with applying Scale property,

 
 
   
By the way i am using WPF and i do not have any Scale property on BlinkSettings model 

At present, we provide this support only in .Net framework. We don’t have support for scale property in blink rendering engine for Net Core. We have logged a feature request for this support in the PDF document. We will include the support for the feature with “Add support for Scale property in Blink rendering engine for .net core” in our upcoming weekly NuGet release on April 5th 2022. 
Please find the feedback link to track the implementation of the feature below. 
Please confirm us, whether you are using .Net Framework or Net Core?

 

Regards, 
Gowthamraj K 



ST Stefano March 25, 2022 02:26 PM UTC

Thanks for your help  Gowthamraj ,currently i am using .net core



GK Gowthamraj Kumar Syncfusion Team March 28, 2022 05:59 AM UTC

Hi Stefano, 
 
Thank you for the confirmation 
 
As we said earlier, we will include the support for this feature with “Add support for Scale property in Blink rendering engine for .net core” in our upcoming weekly NuGet release on April 5th 2022.  
 
Please find the feedback link to track the implementation of the feature below.  
 
Regards, 
Gowthamraj K 



GK Gowthamraj Kumar Syncfusion Team April 5, 2022 11:25 AM UTC

Hi Stefano

Since our 2022 volume 1 main release was rolled out yesterday, we do not have the weekly NuGet release today. We have created a custom NuGet package for this support “Add support for Scale property in Blink rendering engine for .net core” in our latest Volume 1 release version (v20.1.0.47). We will include the support for this feature in our upcoming weekly NuGet release, which we excepted on April 12th 2022.


Using this Scale property we can get the output PDF document like expected scaling behavior. But if we set the value to scale property, then viewport behavior will not work. Since viewport internally handles the scaling of the output PDF documents. We can provide the values from 0.1 to 2.0 for scaling like chrome print to pdf 10 to 200.


Note: Conversion will be failed if the scale property is not in the mentioned range. (0.1 to 2.0).


The custom NuGet package for this fix can be downloaded from the following location,

https://www.syncfusion.com/downloads/support/directtrac/general/ze/Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows.20.1.0.47-2078567241


Please find the below code example for converting html to pdf with Scale property,

            //Initialize HTML to PDF converter with Blink rendering engine

            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);

 

            BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

 

            string path = System.IO.Path.GetFullPath(@"../../../input.html");

 

            //Set the BlinkBinaries folder path

            blinkConverterSettings.BlinkPath = @"\BlinkBinariesWindows\";

 

            blinkConverterSettings.Scale = 1.0f;

 

            //Assign Blink converter settings to HTML converter

            htmlConverter.ConverterSettings = blinkConverterSettings;

 

            //Convert URL to PDF

            PdfDocument document = htmlConverter.Convert(path);

 

            if (File.Exists("BlinkOutput.pdf"))

                File.Delete("BlinkOutput.pdf");

 

            //Save and close the PDF document

            FileStream fs = new FileStream("BlinkOutput.pdf", FileMode.Create);

 

            document.Save(fs);

 

            document.Close(true);

 

            fs.Close();

 


Please refer to the below KB steps to install the custom NuGet package,   

https://www.syncfusion.com/kb/11556/how-to-install-the-customer-patch-nuget-in-windows-machine       

https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf#steps-to-replace-the-patch-assemblies-if-a-customer-using-nuget-packages


Kindly clear the NuGet cache in the global NuGet folder (C:\Users\xxxx\.nuget\packages). 


Please try the above provided custom nuGet on your end and let us know if it suits your requirement or not. 


Regards,

Gowthamraj K



GK Gowthamraj Kumar Syncfusion Team April 12, 2022 12:29 PM UTC

Hi Stefano,

We have included the support with “Add support for Scale property in Blink rendering engine for .net core” in our latest weekly NuGet release (v20.1.0.48). Please use the below link to download our latest weekly NuGet,     

https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows/20.1.0.48


Please let us know if you have any concerns on this  


Regards,

Gowthamraj K


Loader.
Up arrow icon