Jump to content
xisto Community
Sign in to follow this  
suicide1405241470

Java Embedding TIFF image in RTF file

Recommended Posts

Hi,I am trying to write a code to combine RTF file and TIFF file into an output RTF file. That means, output RTF file should have RTF file contents at the top followed by TIFF image. The code is:import java.io.*;public class RTFTest{public RTFTest(String rtfFile, String tifFile){try{BufferedInputStream bis = new BufferedInputStream (new FileInputStream (new File(rtfFile)));int iAvailable = bis.available();byte[] b = new byte[iAvailable];bis.read (b, 0, iAvailable);bis.close();BufferedInputStream bis2 = new BufferedInputStream (new FileInputStream (new File(tifFile)));int iAvailable2 = bis2.available();byte[] b2 = new byte[iAvailable2];bis2.read (b2, 0, iAvailable2);bis2.close();BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream (new File("output.rtf")));bos.write (b, 0, iAvailable);bos.write (b2, 0, iAvailable2);bos.flush();bos.close();}catch(Exception ex){ex.printStackTrace();}}public static void main(String args[]){new RTFTest("./input.rtf", "./test.tif");}}But, when I open the output.tif, I could only see RTF contents. Not sure what happened to the TIFF contents written onto it. Please help me with this.Regards,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.