Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Creating PDF using itext

 
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I’m having a little issue creating PDFS using the itext lib.


This code creates pdfs in the file system one by one.

Everytime I create one I need to get an instance of new FileOutputStream(archivo).

I would like to create PDFs in memory (object), and after having created all of them, write to disk

Is it possible using this lib without making too many changes?

Thanks
 
Rancher
Posts: 43011
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, just write the documents into ByteArrayOutputStreams instead of FileOutputStreams. Then you can write the resulting byte[] to FileOutputStreams when you're done. That will of course use up more memory, which may or may not be a problem under the circumstances.

What is the reason for not wanting to write out files as soon as the documents are created?
 
Fernando Dominguez
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your quick reply!

For whatever reason there were any problems creating any pdf I would have to delete all of them.

So, I think is better to make sure that everything goes well before writting to disk.

Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!