Generate PDF with pie chart -iText7 - itext

The obvious primary reason for using iText being , our company already have a license.
Requirement:
Generate a report that includes pie chart.
Our UX gave us a HTML, And I'm using html2pdf plugin to generate pdf.
We're using tlx-chart for its simplest code.
Issue:
PDF doesn't render/show piechart. No errors seen in logs.
HTML is being created perfectly (Althought iText conversion seems to be not so good), and When I load it with chromedriver as provided in KB article below, it renders overlapped 2 piecharts instead of 1.
So, This knowledgebase article from iText doesn't help.
Infact, I've thought I cannot keep on updating chromedriver,selenium on prod server.
I've to provide a loosely coupled (OS>PDF>PIE) to generate PDF.
Code Snippet:
HtmlConverter.convertToPdf(reportHtml, pdfWriter, new ConverterProperties());
"<tlx-chart id=\"mychart\" chart-type=\"PieChart\" chart-editable=\"true\" chart-columns=\"${['Element','Percentage']}\" chart-data=\"${${pieData}}\" </tlx-chart>"
Please Help!

So the issue is to embed piechart in PDF since JavaScript tags were not being rendered by iText library. And I resolved this in my case using jFreeChart.
Generate an image using jFreechart and embed that image in HTML
iText perfectly renders this as per HTML CSS
For detailed explanation and code snippet on this please visit here
An alternative way is also documented here

Related

How to install Mermaid to render flowcharts in markdown?

I'm trying to render a flowchart in a markdown file using Mermaid. I have a ReadMe.md file in my GitHub repository, and I'd like to include a basic flowchart to help describe the contents. But I can't figure out how to get it to work. Would someone be able to post some more specific instructions on how to render a simple example?
In this link (https://unpkg.com/mermaid#8.0.0-rc.8/README.md), there's an example code snippet for the Mermaid installation:
```
https://unpkg.com/mermaid#7.1.0/dist/
```
I included that code, then tried to make the flowchart in the next code snippet:
```
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
But all it does is print that text out in the markdown file when I preview it.
It seems like it's possible based on the Mermaid ReadMe: https://github.com/knsv/mermaid/blob/master/README.md. But when I looked at the code it's actually a picture of the flowchart, not a rendering of code. So maybe what I'm asking isn't possible?
Would appreciate any help!
I created a Firefox & Chrome extension that wasn't available at the time of the first answer: Github + Mermaid
To use it you will need to specify mermaid as a language:
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
This works on:
PR and issues
Comments
Gists
(both on preview and save)
PS: I'm not sure whether it's right or not to advertise my own work here, but I feel it answers the questions.
Unfortunately, github-flavoured markdown doesn't support rendering of mermaid graphs. See this issue for more information and finding comfort in other peoples quest of this feature ;)
If your are using VS Code, you can use this extension to preview your mermaid code blocks inside markdown but note that this does not render once you put it on github. To include the chart on github you will have to render it to a file, though someone suggested somehow using the online mermaid editor to render it and retrieve an URL to a rendered version.
Actually, let me try to insert the example chart from the link on the previousely mentioned page... and, no. We get a Failed to upload image; the format is not supported-error.
So you will need to save it as an image first.
You can use mermaid-cli https://github.com/mermaidjs/mermaid.cli for generating diagrams. you can produce .svg, .png or .pdf file whatever you want.
Run following command after installing mermaid-cli
mmdc -i input.mmd -o output.png
here input.mmd is your mermaid file which contains
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
in your case.
Another solution in moving your repository to gitlab.
It natively supports mermaid in all markdown files.
Gitlab Markdown Tutorial
Feb. 2022, Markdown pages now officially support Mermaid:
(Note: Aug. 2022, GitHub wiki pages too)
See:
Include diagrams in your Markdown files with Mermaid
Mermaid is a JavaScript based diagramming and charting tool that takes Markdown-inspired text definitions and creates diagrams dynamically in the browser. Maintained by Knut Sveidqvist, it supports a bunch of different common diagram types for software projects, including flowcharts, UML, Git graphs, user journey diagrams, and even the dreaded Gantt chart.
Working with Knut and also the wider community at CommonMark, we’ve rolled out a change that will allow you to create graphs inline using Mermaid syntax:
Gist supports mermaid too.
Jan 2022, while GitHub Markdown does not yet support Mermaid, this is on the roadmap:
"Mermaid diagrams can be displayed within Markdown #372"
Just as language-specific code blocks can be added to Markdown, you'll be able to add a Mermaid diagram using a code block that specifies mermaid as its language identifier. For example:
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
The Markdown code block above uses Mermaid syntax to display this flowchart in the rendered Markdown:
And:
Another example from the Mermaid website shows how straightforward text can be used to create rich diagrams:
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!

Export fusioncharts to pdfMake

I am building a report with pdfMake in which I need to include some charts rendered at the web page with fusioncharts. The available client-side export options provided by fusioncharts aren't working for me because I need to obtain the image file (or base64) somehow to pass it to the function building the document, without having to retrieve it elsewhere.
I understand that fusioncharts have server-side export options, but I haven't found guidence or clear info about if this is kind of the start to the solution I am looking for.
AMcharts has the 'export to base64' feature just the way I need (link below); so any help, tips, solution or workaround to get it done with fusioncharts would be really appreciated.
https://www.amcharts.com/kbase/get-base64-representation-chart-image/
You can get Base64 string data for FusionChart chart by consuming its API method getSVGString, using this method you will get SVG string for the chart which you can convert to Base64 string using JS via window.btoa().
JSFiddle: http://jsfiddle.net/sikrigagan/2ovov3nL/
To know more about this method, check this developer documentation page.

How to integrate ECharts with BIRT/Pentaho?

I'm looking for a report engine which may:
connect to data source via JDBC
create logic data set by grouping/aggregating the raw data
include a data filter on the top of each report, which allows my client use the report interactively
add custom charts, in my case, it's ECharts https://github.com/ecomfe/echarts
support multi-tenancy paradigm (new requirement)
Now BIRT and Pentaho are the two players on my table.
For pentaho, it's really hard to find useful document to at least clarify if it's capable. Please if you're familiar with it, let me know if pentaho community version meets my requirements.
For BIRT, I've found evidence it support my first 3 needs. But for custom charts, I can only find examples/docs about adding custom IMAGE/SVG charts. As ECharts is based on canvas, I'm not sure if it's possible to integrate ECharts with BIRT.
Thank you!
Yes, it is possible to integrate javascript charts in BIRT. Basically:
Select the top-level element of your report outline -> Script tab -> clientScripts
Include here your echart resources (.js and .css) using "head.js" (see link below for more informations)
Add a text element to the report
Set the type of this new element to 'HTML'
In a script tag, initialize your echart object in a "head.ready()" instruction (see link below for more informations). The tricky part is to understand how to use a server-side dataset in a client-side chart within this html script.
You can find more informations and a full example of a such report here, this example embeds a jvectormap in a birt report. Furthermore, see a live demo here, where a JIT chart is integrated in a BIRT report.
However since these charts are created using a client-side framework, obviously BIRT won't be able to export them in PDF format. You can see in the live demo linked above, how a BIRT report can easily handle a different output when users export to PDF.
You can do it in Pentaho, but which tool to use it's a matter of debate.
Using Pentaho Report Designer:
- Connects to DBs using JDBC;
- Allows grouping rows based on a field or fields and calculating functions such as running sums;
- Can use selectors (single or multi-valued selectors) to interact with the report, passing the selector values to the queries;
- As far as I can tell, you don't have many options to choose a specific charting engine.
However, you can use CCC as the charting engine, which is a Protovis based Javascript charting engine, cross-browser compatible (for the most part), renders SVG charts with a decent fallback for IE (I believe the fallback is flash but I'm not sure if it changed recently) and produces decent looking charts.
If you HAVE to use that chart library, then I suggest using C-Tools dashboards instead, where you can embed as many different JS files you want and you have full control over the JS and CSS of the page. But most of the reporting functions from PRD will have to be implmented by you.

signing pdf using itextsharp 5.4.4 - example

Can someone supply an example or a link to an example that signs an existing pdf using itextsharp 5.4.4? Ideally keeping pdf/a conformity of the pdf? Thank you.
Edit: I understand the question looks as if I did not use google etc. BUT, new versions of itextsharp contain completely rewritten code for signing as well as other functions, making the existing examples non-functional. Also, itextsharp started using different names for methods eg. instead of createSignature one has CreateSignature, instead of getSignatureAppearance one seems to have SignatureAppearance etc. making the port from java examples a real nightmare. Also the samples in the source code itself are in java not c#. There is really nowhere else I can go.
Please read http://itextpdf.com/book/digitalsignatures
The examples are in Java, but they were also ported to C#. You can find the C# examples here. I didn't vote your question down, but... the first place to go when you have a question about iText should probably be http://itextpdf.com
The book I refer to (I'm the author) as well as the new examples are on the learn page.

how to generate pdf in GXT/GWT?

i am using GWT/EXTGWT. on click of submit button i get list of records from db. i need to export them to pdf. please suggest me how to do this?
if data to be exported is more then that should be exported to multiple pages.
Thanks!
There's little in context of GWT here, apart from the fact that you have a GWT based application. What you are really looking for is a tool that generates PDF, given data.
There are hosts of them available :
iText
jPDF Writer...
Obviously, iText has been the most widely known and successful one! Here's a good tutorial - http://www.vogella.de/articles/JavaPDF/article.html
Try some tools like itext pdf generator Searching online will give you many more options.