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
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
|
|
Yes, the issue i've reported is wright that slight margin.
Thanks Stefano
|
//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); |
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
|
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? |
Thanks for your help Gowthamraj ,currently i am using .net core
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,
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
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
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