I'm trying to cast a javax.swing.ImageIcon
to a org.pdfclown.documents.contents.entities.Image
so that I can display images in PDF file created by PDF Clown from my Swing application.
I require a ImageIcon because the source image needs to be serializable so that I can store my image as a serialised file as part of a larger, more complex data model.
When I look at the API for PDF Clown I notice Image
accepts 3 inputs;
String
path. - Wont work becauseImageIcon
doesn't have a Path.File
. - Wont work becauseImageIcon
doesn't exist on disk.IInputStream
stream Reference
This means the only viable method is to use an IInputStream
. It is an interface so the only way to construct an Object with that type is to use a FileInputStream
Reference. This accepts a native Java class of RandomAccessFile
Reference. This is another dead end as it accepts only File
and String
.
The solution then must be to write the ImageIcon
as an image to disk then read it back. My concern with this is that I need to use a path to store the images before output that the user wont have restricted access to.
Can I do this without writing to disk first?