JPG -> PDF

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v4)  /  JPG -> PDF

DynamicPDF Generator for Java (v4) Forum

 Oct 14 2008 8:42 AM
Hi!
For a while now we've been converting TIF-files, in memory, to PDF-files to avoid the web browser using Microsoft Document Imaging as a plugin. The code to do this i so simple:

TiffFile tf = new TiffFile(myByteArrayContainingATif);
Document d = tf.getDocument();
d.drawToWeb(httpReq,httpRes,outStream,fileName);

Now we want to do the exact same thing with JPG's and we're totally stuck. Could you provide us with a codesnippet to acieve this?

Regards,
/Pär
 Oct 14 2008 9:04 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can achieve this for the JPG images also without any problem. But it is not possible to convert the JPG images into PDF document directly, you will have to add the JPG image to a page of the PDF document. You can use the image byte array data for this. Following is some sample code for this.

    Document document = new Document();
    Page page = new Page();

    Image imageJPG = new Image(byteArrayJPG, 0, 0, 0.24f)
    page.getElements().add(imageJPG);

    document.getPages().add(page);
    document.drawToWeb(httpReq,httpRes,outStream,fileName);

Thanks,
ceTe Software Support Team.
 Oct 14 2008 12:02 PM
Thanx a bunch!
You guys rule!

All times are US Eastern Standard time. The time now is 12:30 AM.