7

I am created an Excel file using Apache POI. Now I want to convert it into PDF using Apache POI itself or PDFBox.

As per requirements, I can't use itext to convert excel to PDF or any other API other than Apache POI or PDFBox.

Clashsoft
  • 11,553
  • 5
  • 40
  • 79
Rahul Goyal
  • 121
  • 1
  • 5
  • 4
    My suggestion is that you do a bit more research before giving up and posting a question here. There are a ton of resources out there already which probably cover your problem. – Tim Biegeleisen Feb 26 '19 at 05:17
  • Possible duplicate of [Java Apache POI Excel save as PDF](https://stackoverflow.com/questions/26056485/java-apache-poi-excel-save-as-pdf) – Ashok Kumar N Feb 26 '19 at 05:20
  • They are again using itext at some level @AshokKumarN – Rahul Goyal Feb 26 '19 at 05:29
  • 1
    Guide me I have no idea getting in my head where should I move forward @TimBiegeleisen – Rahul Goyal Feb 26 '19 at 05:45
  • @RahulGoyal are you looking for opensource libraries or proprietary too?, if proprietary you can go for ASPOSE PDF, even me also have no idea to do this without Itext even jasper reports using Itext under it – Ashok Kumar N Feb 26 '19 at 05:48
  • @TimBiegeleisen even I also tried, but could not find the solution without itext – Ashok Kumar N Feb 26 '19 at 05:50
  • You can use poi and pdfbox. What have you tried with those libraries yet? What is the blocker? – mkl Feb 26 '19 at 05:56
  • I already used PDFBox and Apache POI. But didnt find anything related. Other then using itext. itext is being used everywhere @mkl – Rahul Goyal Feb 26 '19 at 06:15
  • 2
    Itext is a library to generate pdfs. Pdfbox is a library to generate pdfs. Have you **tried** taking an example using itext and replacing the itext code therein by equivalent pdfbox code yet? If not, why not? That is an obvious approach given your requirements and findings. – mkl Feb 26 '19 at 06:22
  • But PDFBox don't have all the same functionality that itext have. PDFBox dont have any functionality to use existing excel to pdf. In fact there is no option for much formatting in PDFBox like given itext, like doing colspan or rowspan @mkl – Rahul Goyal Feb 26 '19 at 06:37
  • Great, so you have identified specific problems. That's something to build upon. Why don't you show your code as far as it is without that (which should work for simple excel files) and ask for help in implementing those details? Probably different issues should be the focus of different questions. (Your question as is looks like that of someone who didn't try anything himself and expects others to do his job. With the proposed changes it would show that you did try yourself and that there merely are some details you don't know how to continue with.) – mkl Feb 26 '19 at 07:08
  • 2
    The `apache poi` project does not provide any `PDF` export. So your main task will be read the table data out of `Excel` using `apache poi` and write them into a `PDF` using `PDFBox`. So your main question will be: [How to create Table using Apache PDFBox](https://stackoverflow.com/questions/28059563/how-to-create-table-using-apache-pdfbox)? – Axel Richter Feb 26 '19 at 08:23
  • Then I dont think that I need to create Excel File for this. I can directly use data and convert it into pdf using PDFBox. But when dealing with PDFBox you can only create very simple tables. Creating Dynamic table is totally difficult. I have a;lready tried and creaqted whole pdf using it. But the way of creating such PDF is not feasible using PDFBox creating many issues like formatting Tables and other data. Plus performance @AxelRichter – Rahul Goyal Feb 26 '19 at 09:46
  • 1
    So what is your question then? How to program a better `PDFBox` or a better [easytable](https://github.com/vandeseer/easytable)? Well just do it. But don't expect someone will do it for you. And at least don't expect someone will post this whole code as an answer here. – Axel Richter Feb 26 '19 at 09:59
  • 3
    "Creating Dynamic table is totally difficult" - maybe that's why you're paid as a developer, instead of paying for a software that can do it? Developing software is more than just clicking on stuff and copy & paste. From the different products on top of PDFBox, choose the one that comes closest to what you want and improve it. Historically, innovation has often been done by people who were frustrated by an existing product and became active instead of just complaining. – Tilman Hausherr Feb 26 '19 at 11:56
  • I look for that too and I saw this: https://github.com/nakazawaken1/Excel-To-PDF-with-POI-and-PDFBox and will check on that – Osify Apr 04 '22 at 07:00

0 Answers0