So I’ve tried to create a document using an InputStream, but get I try render the docs on a dataTable (I’m using java/jee and jsf) I get a blank when using the getFileName function. I saw someone used a C# where they tried this
Document doc = new Document(myInputStream);
FileSpecification fileSpec = new FileSpecification(myInputStream, fileName);
doc.EmbeddedFiled.add(fileSpec);
I had to try it with doc.getEmbeddedFiles.add(fileSpec), but no luck.
The second parameter of FileSpecification() constructor is file description, not file name. It expects a String Type for the description of file which is being added as attachment to the PDF and it can be retrieved using FileSpecification.getDescription() method. Would you please explain a bit more about your use case and share your sample code snippet along with sample source file(s). Please also share the expected results that you want to achieve. We will further proceed to assist you accordingly.
Thanks for the response. Essentially what was to achieve is upload a document using the web browser, encrypt it with a password, then add it (for now) onto a list for later download.
The MVP for now is just uploading the file, password protecting it, then downloading it
//jsf upload page -> subject to change to use primefaces instead of tomahawk
So firstly, when out of the context of the environment I have to work, I can use the pathToInputFIle or pathToOutputFile ie new Document(pathToInputFile) and document.save(pathToOutputFile) and this will work the way I expect. In my work environmment, I’ll need to pass in the stream to create the document and download it as shown above. firstly the document.getFileName() function returns a blank and after download the pdf, it is password protected as expected, but the file is blank.
document.getFileName() is giving blank because the Document was not initialized with a file name but stream. So, you can use any file name in string format to send the browser to download file with.
Furthermore, the file could be blank due to incomplete bytes in output stream. Could you kindly share a sample web application in zip format with us which implements the complete use case that you are implementing? We will test the scenario in our environment and address it accordingly.
It is good to hear that you were able to sort your issue out. Please keep using our API and feel free to create a new topic in case you need further assistance.