Using WkHtmlToXSharp to convert HTML files, that contain charts rendered by Chart.js, into PDF. Plus a simple download function using System.IO.MemoryStream
- the resource files (js, css etc.) must come with absolute paths.
- Animations if any, will also have to be disabled since there is no delay in redendering available in WkHtmlToXSharp.
- For charts generated using Chart.js, animation, responsiveAnimationDuration and responsive must be set to false.
1. Invoke the procedure
A simple method serves as main method to kickoff the whole procedure. The absolute root path is extracted and used to replace relative paths.
2. Convert a View To HTML String
HTML string is generated directly from a view.
3. Convert HTML string into byte array
4. Register WkHtmlToXLibraries
This registers WkHtmlToXLibraries for the corresponding platform, in this case, Win64.