BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
We are using Syncfusion html to pdf conversion library for generating PDFs out of HTML.
We are using PdfPageTemplateElement class to generate as header object for the PDF.
For some of the generated pages, we want to have dynamic header object, how can we achieve that using Syncfusion PDF to HTML generation
Edit: To be specific, if i have 100 pages of html, on some of the pages of generated PDF, i want a text to appear in the header. Whether the text should appear on PDF header depends on the content of the page
-Balaji
Hi Balaji,
Thank you for reaching out to Syncfusion support.
Our HTML converter internally uses the Blink rendering engine. It utilizes a Chrome headless browser for converting HTML to PDF. It will preserve the PDF document in the same way as the input HTML/URL is displayed in Chromium-based web browsers such as Chrome and print preview. Our converter replicates this same behavior.
We have analyzed the reported issue on our end. Currently, we don't have support to add dynamic Header on particular pages while converting HTML to PDF documents. We internally set the header on every page of the output document. However, we have workaround solution to remove the first page header only. Please refer to the below documentation.
Regards,
Karmegam
Thanks for your reply
How do i edit Header template in already generated PDF and updated a text(header template) in that PDF, do you have an example for that?
-Balaji
We can achieve the reported behavior by removing the existing header using the redaction method and adding the new text. However, we have attached the console sample and documentation for your reference.
Working with Redaction |Syncfusion
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Edit_Pdf_Header_2-1053299190
Kindly try the sample on our end and let us know the result. If you are still facing issues, we kindly request you to share the modified sample, input HTML with resources, complete code snippet, and environment details to check the reported issue on our end. This information will be more helpful for us to analyze and provide you with a prompt solution.
Hi the above solution almost satisfies my requirement, when doing analysis, if i used the below library
Syncfusion.Pdf.Imaging.Net.Core, will it ask for license? when used it, the header showed generated with syncfusion trial library
i have other syncfusion licenses for generating html to pdf via blink libraries like Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Linux
Thanks
Balaji
To prevent trial watermarks from appearing on PDF documents, it is recommended to register a valid license before generating the pdf document. For further details on how to register the license key in your application, please refer to the following user guide documentation.
Overview of Syncfusion license generation - Syncfusion
Hi
Thanks for the reply
I had syncfusion license, do i need to purchase/buy this library Syncfusion.Pdf.Imaging.Net.Core?
Currently, we are checking on this and will update with further details on April 23, 2024.
We have checked the reported issue on our end. If you already have a Syncfusion license for the Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Linux package, you can also use it for the Syncfusion.Pdf.Imaging.Net.Core package. However, all Syncfusion packages must be installed to the major version of the Syncfusion package, such as v22.2.*.
When you are using Syncfusion assemblies\NuGet packages from nuget.org or a trial installer, you should generate and register the corresponding version and platform license key in your application to avoid a trial license warning.
Syncfusion license keys are major version and platform-specific and please, ensure that all the referenced Syncfusion assemblies\NuGet packages are all on the same version as the license key’s version in your project.
Refer to the below KB article to know which version license key should use in the application,
Please, ensure that all the referenced Syncfusion assemblies\NuGet packages versions are all on the same version as the license key’s version in your project.
Refer to this link for generating the license key,
https://help.syncfusion.com/common/essential-studio/licensing/how-to-generate
Refer to this link for registering the license key,
https://help.syncfusion.com/common/essential-studio/licensing/how-to-register-in-an-application
Note: If you are using any template file for generating the PDF document, please ensure that the original template file doesn’t have any license trial warning
Sometimes, old Syncfusion packages might be referred from the NuGet cache in the project.
So, could you please try cleaning your project, clearing the NuGet cache from both the “%userprofile%” folder and the NuGet installed location, deleting the bin\obj folders, and rebuilding your application, then check whether it resolves the issue?
If the reported issue is still not resolved, please share the following details to check the issue further from our side,
Please let us know if you have any concerns.
Hello,
Is there any support for adding a dynamic header?
Or can you guide me to any workaround for this?
My use case is that I have a header which is generated dynamically and might get lengthy, so I cannot hardcode any padding or margin to create space for header and footer.
I am thinking of somehow getting header height and then add this property in the html body.
Hi Sumrender,
We have reviewed your query, and after further analysis, we found that you can determine the height of the HTML header using the GetHtmlBounds() method. This method allows you to retrieve the dimensions (width and height) of the HTML content based on the current settings, such as the viewport width and scale.
By using the dynamically calculated height from GetHtmlBounds(), you can set this value as the top margin in the BlinkConverter settings. This approach should address your requirement of handling a dynamic header without the need for hardcoded padding or margins.
For further reference, please find the documentation for the GetHtmlBounds() property here:
Converting HTML to PDF | GetHtmlBounds | Syncfusion
Additionally, we’ve included a sample along with its corresponding output document for your review.
Please try the provided sample on your end and let us know the results. If you encounter any issues, we kindly ask that you provide more details about your specific requirements, along with sample input and HTML documents, as well as the expected output PDF. This will help us better understand your use case and offer a more tailored solution.
Regards,
Arumugam M
Hi Arumugam,
Thanks for the quick response. I tried using GetHtmlBounds but it is not giving correct height.
I've attached a link of the POC that I tried. The main requirement is to have dynamic headers, as the headers sometimes get as long as half the page.