cnescatlab / sonar-cnes-report

Generates analysis reports from SonarQube web API.
GNU General Public License v3.0
471 stars 159 forks source link

PDF output of the docx file #158

Open jagdish9 opened 4 years ago

jagdish9 commented 4 years ago

Is it possible to generate the pdf output of the same docx file, does plugin has inbuilt support for the pdf output.

Sancretor commented 4 years ago

Hi @jagdish9

Thanks for your interest, we appreciate it !

Unfortunately, the plugin is not able to generate a PDF from the docx file in 3.2.2. I'm not sure it will some day, because you can do that with LibreOffice or Word. Does this answer your question ?

jagdish9 commented 4 years ago

Hi @Sancretor,

Thanks for your reply !

Yes, I can do with LibreOffice or Word, The problem here is I need to install LibreOffice on every machines. I tried with XDocReport (Apache POI XWPF), It is able to convert only after editing once. Please find steps: steps:

  1. Generate the docx report.
  2. Tried to convert this docx report to pdf, getting below error.

fr.opensagres.poi.xwpf.converter.core.XWPFConverterException: java.lang.NullPointerException at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:71) at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:39) at fr.opensagres.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:46) at com.ConvertTest.main(ConvertTest.java:23) Caused by: java.lang.NullPointerException at fr.opensagres.poi.xwpf.converter.core.utils.XWPFTableUtil.getWidth(XWPFTableUtil.java:274) at fr.opensagres.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:285) at fr.opensagres.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:128) at fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.visitTable(XWPFDocumentVisitor.java:970) at fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:267) at fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:215) at fr.opensagres.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:57)

  1. Open the docx file and edit something and saved.
  2. Tried to convert this docx to pdf, it converted to pdf, yes it worked in this case.

Note: only after editing once it worked

jagdish9 commented 4 years ago

Hi @Sancretor,

We want that docx should be converted dynamically at the run the time. is that possible ?

Thanks.

Sancretor commented 4 years ago

Hi @jagdish9

I don't know why your PDF converter does not work, and won't be able to debug it as it is outside of the scope of this project. I perfectly understand that your need is to have a PDF output, but currently, the plugin is not able to do it. Maybe have a look at a tool like pandoc ..?

We could investigate on how to do it, but honestly, we may not do it soon or ever. Sorry. In our minds, the generated documents are just preliminary versions of what you would have to produce to give a clear state of your code quality, so they still need manual editing to add further information from your own analysis.

begarco commented 4 years ago

Hi @jagdish9

This is a known behaviour of the cnes report. By construction, the generated document only contains references to the targeted values. At document opening, references are replaced by the values by the word processing application. So that it may be understandable you get null pointer exception when trying to handle the reports with low level tools.

It may be enhanced, but may need some time to fix it the right way: feel free to contribute if you have time to do so.

Thanks, Benoît