How to convert TestNG report index.html to pdf - java

I am trying to convert TestNG report to PDF.
I have tried so many options present on google but all are converting HTML code to PDF but I required replica of index.html or emailable report to PDF.
Many are offering different plug-ins.. I do not have problem with them unless there presentation and information​ they sharing is some what equalvent to TestNG report.
I understand the index.html have other dependansies like css and other things like images.
Can anyone suggest a good option.
Please specify the jars required and import if possible.
It will really help :)

If you want a pdf report, you can use this TestNG extension: http://uttesh.com/pdfngreport/
Or you can write your own by implementing the IReporter interface, and maybe combined with IText or any other pdf generation lib.

If don't want to use above plugin and you just want to convert your index.html, you can refer the following thread.
A java library for converting xml/html to pdf

Related

Is there a way to get Concordion test results output into pdf format?

By default the concordion framework records test results into html format. Is there any extension or way to get it create a pdf instead? Any pointers?
Not that I know of currently. You could try using a library like openhtmltopdf to convert the output html to pdf. If you do this, please let us know, we may be able to add it in as an optional extension.

Generate an HTML report with BIRT from an HTML Template

In a project I'm working on, we're using BIRT to generate some HTML reports from some XML Traces.
However these reports are pretty simple and ugly and we wish to improve them. We made a mockup/template in HTML/CSS (and some JavaScript that we want to be embedded in each reports) but now that we're happy with the design, there seem to be a problem (that we should have seen before):
Can we use this template with BIRT? AFAIK, we have to design the birt template using birt's tools ; and it'll be a lot of (useless) work to do so, and we're not even sure we'll be able to obtain the same design with birt as we tweaked things very tightly with CSS.
You can give bookmarks to all of your visualizations in the BIRT report and then use the JavaScript API to display the content in your template. Alternatively, if you are building even the visualization in the HTML template, you can use the REST API to extract data into JSON format and then visualize that as you like in your HTML pages.
You could also load the external CSS file with the BIRT report.

Creating Docx, PDF, XSL-FO

[Background Info]
We had a solution in place to use Word automation serverside to convert HTM documents into Docx, PDF or Print documents. This solution broke in the latest version of Windows Server 2012. We learned that MS does not intend on Word working in this manner and after trouble shooting with MS support Engineers we have come to the conclusion that it will never work.
[Currently]
I am currently researching potential technologies and tools that my company can use to regain this functionality. We need to be able to create Docx, PDF and print files to a local printer.
I have looked into a number of tool already and I am currently leaning towards Apache FOP this seems to handle PDF and Printing for us.
However, I'm looking for some advice and suggested tools that we could use to implement a pure Java approach. Currently our application creates HTM files with all the required information. So ideally we would like to take these HTM files and "Convert" them into Docx/XLS-FO format.
[Question]
So my question that I'm hoping you will be able to help me with.
What is the best tools that I can use to get from
HTM to Docx
HTM to PDF
Or what would be the best process for achieving this? has anyone had success finding a solution for this in the past?
Thank You
It depends on the level of control and the complexity of the source HTML. There are HTML to FO stylesheets but you might find them wanting for your specific need.
So you could use the Jericho parser to read the HTML and generate FO. Or you generate the target format directly using Apache PDFBox and Apache POI
It all boils down to the level of control you want/need
docx4j-ImportXHTML will get you from XHTML to docx. From there, you can use docx4j (or some other solution eg LibreOffice/OpenOffice) to do docx to PDF.
docx4j supports docx to XSL FO, and by default uses FOP.

Using templates for creating PDF files

I have some PDF template (with header and footer). I want to generate documents that are based on that template.
Is there any way to do that with iText? Thank you
P.S. Right now I am generate a document on-fly i.e. every time I generate header, footer and the context itself.
UPDATE: I have found incredible library called PD4ML. It's not free, but not such expensive, BUT it has really cool features such as HTML2PDF conversion on fly, supports a lot of HTML-CSS tags and has even its own jsp tags library! So I really suggest it when you need something instead of heavy and memory-eating JasperReports.
You can use JasperReports library and the iReport visual designer.
JasperReports use iText to produce PDFs from "jasper" templates, that are XML files (following the jrxml DTD) compiled in java classes, but allows you to use the template for generating MS Office files (with POI), html, etc.
Im not sure with iText, but you can use BIRT for this purpose. http://www.eclipse.org/birt/ Its too much using it just for PDF creation, you can do a lot (more than you can imagine) with it.
If you can choose your template format. I would go with JODReport and JODConverter.
JODReport use an ODT template and fill the mapping in the template with your java code.
JODConverter use LibreOffice to convert such template in PDF or whatever fortmat LibreOffice can handle to export.
You have to be able to use LibreOffice as a service installed remotely on a machine.
I used it back in 2012 but not sure if the project is still active

Converting .xls to .pdf using Java(or not)

Is there a way to convert a xls file into a pdf?
I want to make a dynamical report directly to pdf file, but didn't find a way to make dynamic columns on iReport, so I've made a method on Java that exports to xls dynamically.
So I was wondering if is there a way to convert this file to pdf, but it need to be on a method from my code. Or if you have a better idea, it can be used too.
Maybe there's a way to make this pdf file from my code as I did with xls. Please help me out.
Thanks.
Try using iText http://itextpdf.com/ - I've used it to create PDFs with columnar structure.
In addition to using iText directly, there are a couple report engines that sit on top of it:
Eclipse BIRT (using 2.1.7, the last MPL/LGPL version)
Jasper Reports (which uses a Very Old version, 1.3.1 IIRC)
This is a commercial solution:
http://www.dancrintea.ro/xls-to-pdf/
If you want open source try jakarta POI.
Try using the Muhimbi PDF Converter Services. It comes with a Java compatible Web Services based interface and sample code. It does other things as well.
I worked on this application, so the usual disclaimer applies.

Categories

Resources