I have to attach a pdf file in a pptx slide during runtime.
Tried the following:
Attached a pdf file in the pptx slide (Insert -> Object -> Adobe Acrobat Document).
Accessed the oleobject using the following code :
OleObjectBinaryPart oleObjectBinaryPart = new OleObjectBinaryPart(new PartName("/ppt/embeddings/oleObject1.bin"));
Updating the oleObjectBinaryPart using the following code:
oleObjectBinaryPart.setBinaryData(reportBlob.getBinaryStream());
Updating the pptx with the new oleobject:
pptMlPackage.getParts().getParts().put(new PartName("/ppt/embeddings/oleObject1.bin"), oleObjectBinaryPart);
pptMlPackage.save(new File("C:/test_report/pptx_out.pptx"));
After executing this code the pptx_out.pptx file got generated without any errors. But while trying to open the embedded pdf in powerpoint 2010 I'm getting following error:
The server application, source file, or item can't be found, or returned an unknown error. You may need to reinstall the sever application.
Is it a problem with the oleobject when updating?
You can't just attach the PDF as a binary blob; it has to be in the correct OLE format.
See further this discussion.
Related
I have an app that automatically processes a range of excel files but i have one issue. For some files I have what seems to be an html file with a .xls file extension (opening in excel gives corrupt warning and resaving shows it wants to save as an html).
When using Apachi POI:
try (Workbook wkbk = WorkbookFactory.create(myCorruptFile)) {
//myCorruptFile is of type File
This fails to process with apache poi NotOLE2FileException error below
Invalid header signature; read 0x0A0D3E6C6D74683C, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document, { }
If I manually resave as a .xls the file will process appropriately, but is there a way to detect and resave/convert this file via java 11? Manually converting the files isn't an option for me as opposed to an automated one.
myCorruptFile.getContentType()
Gives content type as:
application/vnd.ms-excel
And using Apache Tika gives detected type as:
tika.detect(myCorruptFile.getBytes())
text/html
(My maven pom has no filtering)
I am using the Fedex API com.fedex.ship.stub.CompletedShipmentDetail to generate a COMMERCIAL_INVOICE pdf for international shipment, but the generated PDF file fails to print. There are some other pdf files also generated along with this file but they are printing fine. I checked the metadata of both pdf files and observed some differences.
One which is not printing:
PDF Producer: iText 2.1.2 (by lowagie.com)
PDF Version 1.5
One which is printing:
PDF producer: FedEx Services
PDF Version: 1.4
I verified that there is no bug in the code. The same code is able to print some pdf files and not printing the other pdf file. Files are present in the path.
The print is done using the following command from a Linux machine to a Printer:
lp -d <PRINTER_NAME> -n 2 <FILE_PATH>
I want to append into the existing text file. For that I have tried all this in plenty of way FileWriter,BufferedWriter,PrintWriter,RandomAccessFile,OutputStream,FileOutputStream,PrintStream but I can't get my desired output.
This error java.io.FileNotFoundException: could not open file '//file:/usr/backupdata/5605.txt' using mode 'a+' sucks. (I am working with ewon flexy hardware which supports javaetk 1.4 only)
You are trying to use a url as a file name. That won’t work.
Use
/use/backupdata/5605.txt
as the file name.
I have a .dot file using which i will be creating doc file with values replaced.
eg: .dot file having <claimId>
I will replace <claimId> with real claim Id say 1234 and generate a doc file.
I am using Apache POI HWPFDocument, when using HWPFDocument i am getting issues when i replace text inside table.
So i tried XWPFDocument i can feed only .dotx files.
I have no issue when using dotx file with XWPFDocument and successfully generated docx files. Now i need to convert .dot files to .dotx files from java.
Can someone help me on this...
There is no automated way to do this conversion in Apache POI as far as I know.
You can manually convert .dot files to .dotx by opening the file in Microsoft Word and saving it in the newer format.
Is there a system property or other parameter that can be passed to PDFBox when attempting to convert from a PDF document into an Image? I am utilizing the provided PDF2Image class like so:
String[] args = new String[]{"-imageType", "jpg", "myfile.pdf"};
org.apache.pdfbox.PDFToImage.main(args);
It works great on Windows and fails with this warning on Ubuntu:
[org.apache.pdfbox.util.PDFStreamEngine] java.lang.NullPointerException java.lang.NullPointerException at org.apache.pdfbox.pdmodel.font.PDType1Font.getawtFont(PDType1Font.java:261)
I assume from my research that this is a problem with a "missing" font, but I've found very little help so far using google and the projects website.
I've tried both versions 1.7.1 and 1.8.2 of PDFBox.
Similar question here: setting ttf for PDF to Image on PDFbox