Essential PDF vs HTML to PDF converter

Hi,

from your documentation, it's not clear what is the best solution in a scenario like this:

- Blazor Webassembly application Hosted (client dashboard and server API)

- convert some of the dashboard pages in one PDF with almost the same content (user request pressing a button)

- each page contains text, charts and grids (syncfusion blazor components)


Essential PDF

From documentation:

https://help.syncfusion.com/file-formats/pdf/create-pdf-document-in-blazor#steps-to-create-pdf-document-in-blazor-client-side-application

you can recreate every page adding manually again each text and table. But what about charts? I didn't find any help document about that.

Moreover, this solution requires rewriting all the dashboard pages and positioning manually each component. Is it right?


HTML to PDF Converter

From documentation:

Converting HTML to PDF with WebKit engine | Syncfusion

It's not clear if the solution works in a Webassembly Balzor app. If not, is there a workaround? For example, using the server-side of the hosted application.

Using this solution, can you convert directly the dashboard pages and their content (maybe with another main layout) ?  

I know there are specific WebKit libraries for windows/linux/mac, but which one do I have to use? Especially if the development environment is a Windows PC/Server, but the production one is a Linux Docker image.



7 Replies

GK Gowthamraj Kumar Syncfusion Team July 1, 2021 01:53 PM UTC

Hi Maurizio, 
 
Thank you for contacting Syncfusion support.  
 
Queries 
Response 
Queries regarding Essential PDF 
You can create pages with text and table, you can add the charts as images in PDF pages. Yes, you need to create and add the components from dashboard page to PDF page by positioning manually.   

Please refer below links for more information, 
Queries regarding HTML to PDF converter 
Our HTML to PDF converter will only in Blazor server side app. Using HTML to PDF converter, we can render the dashboard page to PDF document directly. 

Yes, we have specific binaries based on the platform. You can use it based on your development and production environment.  

If you are using windows for development environment, you need to choose windows binaries. When you are moving to production, you need to choose Linux binaries.  Please refer below links for more information about HTML to PDF conversion in Blazor and Linux docker.  



 
Please let us know if you need any further assistance on this.  
 
Regards, 
Gowthamraj K 



MZ maurizio ziraldo July 2, 2021 11:05 AM UTC

Hi,

thanks for the links.


About Essential PDF, the example implements a winform solution. In our case, we work with a Blazor WebAssembly Hosted application and it's mean the execution of the code is client-side:

- is still valid the example? I mean, can I use the same library/methods in a Blazor context?

- the PDF creation is in background: there are no controls "to export from a page", but we should create them dynamically by code in the background and insert them into the pdf to send back to the user. Is still possible?


The HTML to PDF conversion is clear, but probably less useful in this context.


Regards.






GK Gowthamraj Kumar Syncfusion Team July 5, 2021 10:44 AM UTC

Hi Maurizio, 
 
Thank you for the update.  
 
The provided KB article is published for Windows Forms platform. Using the same way we can achieve that in Blazor with PDF .NET core library. There will be a changes in the code snippet for saving and loading the images.  
 
We can add the text, images, shapes to PDF document in background in Blazor. If we have all the details (chart, grids) in text and images, then it is possible to generate PDF documents in background. Please refer below link for more details, 
 
Please let us know if you need any further assistance on this.  
 
Regards, 
Gowthamraj K 



MZ maurizio ziraldo July 5, 2021 03:09 PM UTC

Hi,


this is clear. Let's try with an example. If I have to put a chart on a Blazor page, I write a code like this one:

                        <SfChart>

                            <ChartEvents OnAxisLabelRender="onChartAxisLabelRender"></ChartEvents>

                            <ChartLegendSettings Visible="true" Position="LegendPosition.Top" Alignment="Alignment.Far" Height="10%">

                                <ChartLegendTextStyle FontFamily="Roboto" FontWeight="500" Size="10px"></ChartLegendTextStyle>

                            </ChartLegendSettings>

                            <ChartArea><ChartAreaBorder Width="0"></ChartAreaBorder></ChartArea>

                            <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.DateTime" LabelFormat="dd/MM/yyyy" IntervalType="IntervalType.Days" LabelIntersectAction="LabelIntersectAction.Rotate45" EdgeLabelPlacement="EdgeLabelPlacement.Hide">

                                <ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>

                                <ChartAxisLabelStyle FontFamily="Roboto" FontWeight="500" Size="10px"></ChartAxisLabelStyle>

                            </ChartPrimaryXAxis>

                            <ChartPrimaryYAxis>

                                <ChartAxisLabelStyle FontFamily="Roboto" FontWeight="500" Size="10px"></ChartAxisLabelStyle>

                                <ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>

                                <ChartAxisLineStyle Width="0"></ChartAxisLineStyle>

                            </ChartPrimaryYAxis>

                            <ChartSeriesCollection>

                                <ChartSeries DataSource="@_chartserie" Name="CASHFLOW" XName="Date" Opacity="0.7" YName="Value" Fill="Color" Type="ChartSeriesType.Area" TooltipMappingName="Label">

                                </ChartSeries>

                            </ChartSeriesCollection>

                        </SfChart>


Now I want to create dynamically on a server-side API the same chart by code, export it in an image to put in a PDF/Word. Can I write a code like:


            SfChart chart = new SfChart();


            ChartSeries series = new ChartSeries(chart);


            series.Type = ChartSeriesType.Area;


(...)

           

            chart.Export(ExportType.JPEG, "chart.png");


and then using the image in a PDF/Word?


Thanks




GK Gowthamraj Kumar Syncfusion Team July 6, 2021 02:01 PM UTC

Hi Maurizio,  
 
Thanks for your update.  
 
We have checked your requirement on our end. We would like to know that there is no possibility to create blazor charts dynamically. You have to use in tag as in a previous sample.  
 
 
Note: We can add only add a series of chart dynamically using SfChart control. It is not possible to create entire blazor charts dynamically.  
 
Kindly revert us, if you have any concerns.  
 
Regards, 
Gowthamraj K 



MZ maurizio ziraldo July 8, 2021 06:10 AM UTC

Ok, thank you. It's clear.

We will find another solution.

Regards.



GK Gowthamraj Kumar Syncfusion Team July 8, 2021 11:24 AM UTC

Hi Maurizio,  
   
Thanks for the update. Please let us know if you require further assistance.  
   
Regards, 
Gowthamraj K 


Loader.
Up arrow icon