Hello, I have been tasked with creating a PDF command line by pulling a
string from a third party machine and creating a pdf that can be archived onto a new server.
Currently, i have an web app that pulls the string from the third party machine and renders the pdf in the browser.
I have taken parts of that code and tried to create a pdf. The pdf gets created but then I am unable to open it because it is "not a supported type or it is damaged".
Here is the code I am using to create the pdf:
*baos is the inputstream I get from the third party machine converted to a ByteArrayOutputStream.
Document document = new Document();
FileOutputStream myFile = new FileOutputStream(pathDate + accountNbr + ".pdf");
baos.writeTo(myFile);
PdfWriter writtenPdf = PdfWriter.getInstance(document, myFile);
document.open();
System.out.println("good pdf" + baos.size());
myFile.flush();
if (myFile != null) {
myFile.close();
}
I thought I had it working but do not. I was looking for some guidance for what i may be doing wrong?
Thanks.