I am building html
views with stringbuilder
and using DinkToPDF
to convert this HTML to a pdf. I have been able to add a header and footer using the following(By creating static HTML
pages:
var objectSettings = new ObjectSettings
{
PagesCount = true,
HtmlContent = await _template.Build(data, hostUrl),
//HeaderSettings = { HtmUrl = hostUrl + "/views/v1/getview?reportName=AcademicTranscript&viewName=test.html&themeName=SchoolTheme_SchoolId",
HeaderSettings = { HtmUrl = hostUrl + _swaggerConfig.BasePath + "/views/v1/getview?reportName=AcademicTranscript&viewName=portraitheader.html",
Line = true, Right = "[page]/[sitepages]", Spacing = 5 },
FooterSettings = { HtmUrl = hostUrl + _swaggerConfig.BasePath + "/views/v1/getview?reportName=AcademicTranscript&viewName=portraitfooter.html",
Line = true },
};
This works great, but I need to add a custom html
view as part of the header, which contains details, such as Name, surname, address etc.
Is there a way of adding a custom built page(meaning Html tags etc. with information from the Database) to the header?
I hope my question makes sense.
Thanks for any help.
It seems that at the moment there are 2 ways to setup a document header content in HeaderSettings in DinkToPDF :
Left
, Center
, Right
properties with a plain textHtmUrl
propertySo you can retrieve the needed data from a database, fill an HTML header file with HTML renderer like this one , pass the header file's path to HeaderSettings.HtmUrl
property, generate your PDF document with DinkToPDF and delete the header file afterwards.
An example for generating HTML files by template can be found here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.