Hi,

Thanks for the reply. I am using itext 5.5.3. and below is the sample code


void convertTiffToPDF (*final* PdfContentByte oContentBytes, *final*
P8Document oCEDocument, int nEndPage, int nStartPage)

RandomAccessFileOrArray oPage = *null*;

*int* nTiffPageToRead = 0;

*int* nContentElement = 1;

// make sure we don't try to read more than we have

*int* nLoopEnd = nEndPage;

// single content element, write all pages

oPage = *getContentElement*(oCEDocument, 1);

nLoopEnd = TiffImage.*getNumberOfPages*(oPage);

*int* nOutputPage = 0;

*for* (*int* i = nStartPage; i <= nLoopEnd; i++)

{

nOutputPage +=1;

// Read the page content from CE and determine which *tiff* page to get

*if* (nContentCount > 1)

{

// multiple contents elements each a single page
*tiff*

nContentElement = i;

nTiffPageToRead = 1;

oPage = *getContentElement*(oCEDocument, i);

}

*else*

{

// *multipage* *tiff* in a single content element

nContentElement = 1;

nTiffPageToRead = i;

*if* (i == nStartPage && oPage==*null*)

{

oPage = *getContentElement*(oCEDocument, 1);

}

}

*try*

{

// Get the image content from the page

*if* (nTiffPageToRead<=TiffImage.*getNumberOfPages*(oPage))

{

*final* Image oPageImage = TiffImage.*getTiffImage*(oPage,
nTiffPageToRead);

//set the global seek value to 0 for the next page

//otherwise it may cause EOFFileException while converting subsequent pages

oPage.seek(0);

// Adjust the page size to the image dimensions. Each content

// element can have its own dimensions

// the default for the PDF is 72 *dpi*, so adjust for *whats* in the
*tiff*

*float* width = *getOutputWidth*(oPageImage);

*float* height = *getOutputHeight*(oPageImage);

oDocument.setPageSize(*new* Rectangle(width, height));

// Create a new page

oDocument.newPage();

// Position the image at the upper left corner since the page

// has been sized to the image

oPageImage.scaleAbsolute(width, height);

oPageImage.setAbsolutePosition(0,0);

// Add the image to the page9

oContentBytes.addImage(oPageImage);
}


* private* *static* *float* getOutputWidth(Image oPageImage)

{

// a *jpg* with a DPI of 100 in viewer is reporting 1 in iText

//*int* OriginalType = oPageImage.getOriginalType();

//float *nheight* = oPageImage.getPlainHeight();

*int* dpi = oPageImage.getDpiX() == 1 ? 100 : oPageImage.getDpiX();

*return* dpi > 0 ? (oPageImage.getScaledWidth() * 72.0f)/ dpi :
oPageImage.getScaledWidth();

}

*private* *static* *float* getOutputHeight(Image oPageImage)

{

// a *jpg* with a DPI of 100 in viewer is reporting 1 in iText

*int* dpi = oPageImage.getDpiY() == 1 ? 100 : oPageImage.getDpiY();

*return* oPageImage.getDpiY() > 0 ? (oPageImage.getScaledHeight() * 72.0f)/
dpi : oPageImage.getScaledHeight();

}
I am not able to share any of the tiff but those are scanned document.

Thanks,
On Wed, Nov 26, 2014 at 6:16 PM, iText mailing list <i...@1t3xt.info> wrote:

>  On 11/25/2014 16:18 PM, susmita sil wrote:
> > Hi,
> > I am reading Tiff image from IBM filenet as java outputStream. I am
> > converting the outputStream to itext Image and the converting that
> > image to PDF. The converted PDF has good resolution but size is bigger
> > than the tiff image for example it I have a 10 mb tiff imge its
> > becoming 90 mb and its crashes the server. I need to decrease the size
> > of PDF.
> > Any help will be appreciated.
>
> Depending on the nature of the TIFF, the image can be stored in a very
> compact way (e.g. black and white CCITT image) or in a less compact way.
> It all depends.
>
> You shouldn't expect any answer without sharing a code sample (including
> which version of iText you are using) and more importantly some of the
> TIFFs that produce the problem.
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to