I am using apache-poi api to create a word document.
I want to insert a PDF document into MS Word (normally we use Insert -> Object -> Create from file option in MS word to do this).
Is is possible to insert the PDF as an object into MS Word using Java ?
Regards,
Suthershan
To solve this you have to use OLE. After a quick research I found no example code for WORD but I found some code for EXCEL and an example for PPTX. Maybe it is helpfull to write some corresponding code for WORD.
Related
I'm trying to perform automaticaly table extraction inside PDF. I know there are several libraries and methods Java and Python, but to my surprise, the method that has worked best for me is to convert my Pdf to a Docx document and from there to extract the tables (thanks to: How to get pictures and tables from .docx document using apache poi?).
My question is this: Assuming that within the format conversion there may be loss of information, why are my results better this way? Tabula hasn't been able to do better automatically. To understand this, I have looked for information (e.g. Extracting table contents from a collection of PDF files) but I'm still very confused.
PD: For the moment, I have used https://github.com/thoqbk/traprange (A method based on Pdfbox), How to extract table as text from the PDF using Python? (PyPdf2) and Tabula. When I get to my home I going to put code and cases, I'm writing from my smartphone.
I have a requirement to write data into ms-word in "Envelope Label" format.
I have used poi api XWPFDocument which is supporting table creation.
Can any one please suggest which library does supports the requirement and if possible please can you give me sample example.
Thank you,
Kavitha
you may use a Word Template and replace the placeholder with real value.
Please refer to the sample in link: link to replace text in MS Word using Apache POI
I generate csv file in Java code. I use org.apache.commons.lang3.StringEscapeUtils to escape values for csv. Some values contain line breaks. When I open the resulted file in Open Office everything is OK. However when I open it in Microsoft Excel 10 the table is garbled - the text on new line is moved to another cell breaking the whole structure. Is there a way to escape line breaks in Java, so that csv will open properly in Excel?
Use a CSV library to handle this for you. Example with univocity-parsers
List<Object[]> allRows = getRowsToWriteFromSomewhere();
new CsvWriter(Csv.writeExcel()).writeRowsAndClose(allRows);
Hope this helps.
Disclaimer: I'm the author of this libary. It's open-source and free (Apache 2.0 license)
I have to read a text file and write it to an already existing excel file. The excel file is a customized excel sheet with different items in different columns. The items has different values for each of them... These items with there value can be found in a text file. But i dont have much idea as to how to do this.
E.g- example.txt
Name: John
Age=24
Sex=M
Graduate=M.S
example.xlsx
Age: Sex:
Name: Graduate:
Thanks in advance :)
Just as for so many other problems that need solved, there's an Apache library for that! In this case, it's the POI library. I've only used it for very basic spreadsheet manipulation, but managed that by just following a few tutorials. I'd link to one, but I can't now remember where it was.
Please see Apache POI-HSSF library for reading and writing Excel files with Java. There are some quick guides to get you started.
This post How to read and write excel file in java might help you.
You can also create a *.csv (comma separated value) file in Java. Just create a simple text file with CSV extension and put your values in there like that :
Age:,24,Sex:,M,
So you just separate your values with commas (or other delimiters like ';').
Every line in this file is a row, and every delimiter separates two columns. You won't be able to add colours/styles/formatting this way, but it gives you a file that is openable and understandable even without Excel (or other spreadsheet software).
I want to convert ms word document to PDF file using POI.jar(read the MS word Content) and Itext.jar(Creat the PDF File).
For Plain text in MS word, I am able to conver into PDF. But I have few images on ms word. I want to put those images on PDF.
Could some please help me out?
You lucky man i just stumbled upon JODConverter it uses openoffice to covert through java and its very easy to use.
There isn't such a solution for free, you will have to buy something like Aspose components, but you can also save the Word document as HTML and use any of the available HTML-to-PDF tools to convert it to PDF using Java. One of them is wkhtmltopdf.