We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Direct to File mode in Java - PDF not getting updated

Hi, I am working with large pdf files and need to use direct to file mode.


I am not able to add anything to the pdf file when i use following example code. What am I doing wrong?

I access the pdf file using FileInputStream. Create Pdf instance with it.
Get sections. use section.addParagraph to add a text object to pdf.
then use Pdf.close()

But my pdf does not get updated.

Sample code -
FileInputStream inputStream = new FileInputStream(“file path”);

Pdf pdf123 = new Pdf(inputStream);

Section section = pdf123.getSections().add();

Text text = new Text(“This is new page”);

section.addParagraph(text);

pdf123.close();

Also another forum link points to code which used ‘BinaryFileStream’ which apparently is removed from the latest distribution of Aspose.pdf. But the code did something like setCanWrite(true);

Is the ‘can write’ part missing when we use file input stream?

Thanks for any inputs.

Regards,
Ashwin

Hi Ashwin,


Thanks for your inquiry. Please note aspose.pdf (legacy Aspose.Pdf for java) is used to create new PDF document. You may use com.aspose.pdf package or com.aspose.pdf.facades package to edit work with existing PDF documents and can use direct to file mode as well.

Please feel free to contact us for any further assistance.

Best Regards,



Thanks for confirming my doubts.


But again I cannot find any documentation which help me use the facades package as direct to file writing mode.

Can you please give me some pointers?

I was told in a chat conversation with one of your colleague that bindPfd on PdfContentEditor will load the entire pdf file which needs editing, which will not solve my problem.

Regards,
Ashwin
ashwin.nikam:
Also another forum link points to code which used 'BinaryFileStream' which apparently is removed from the latest distribution of Aspose.pdf.
Hi Ashwin,

I have also observed that BinaryFileStream is missing from aspose.pdf package of Aspose.Pdf for Java API. For the sake of correction, I have logged it in our issue tracking system as PDFNEWJAVA-34206. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Thanks Shahbaz.


But i still dont have a way to write my pdf direct to file using java. As mentioned in one of the comment can i use facades to do it?

Or do I need to wait for the issue with BinaryFileStream is fixed.

Hi Ashwin,


Direct to file mode is supported by aspose.pdf package and its useful when creating large PDF files. However when using an existing PDF file, you do not need to use direct-to-file mode. The com.aspose.pdf.Document class present in com.aspose.pdf package and the classes present under com.aspose.pdf.facades package can load existing PDF files and there is not specific restriction regarding the size of input file. You may try using this approach to load files of any size. In case you encounter any issue while using either approach or you have any further query, please share the resource files and the code snippet so that we can further investigate the issue at our end.

I would recommend you to visit the following links for further information on