The image may be very big. Try img.scalePercent(10).
Paulo
> -----Original Message-----
> From: vojtik [mailto:[email protected]]
> Sent: Wednesday, November 18, 2009 8:51 AM
> To: [email protected]
> Subject: [iText-questions] PDF generated from TIFF is blank - vol.2
>
> Hi,
>
> sorry but I don't know what is 'media box'. To generate PDF
> from TIFF, I use this code:
>
> public IDfDocument tiffToPdf(IDfDocument doc) throws DfException {
> if (!doc.getContentType().equals("tiff")) {
> System.out.println("Doc isn't tiff document");
> return null;
> }
> String tiff_file = doc.getObjectName();
> String pdf_file;
> if (tiff_file.lastIndexOf('.') >= 0) {
> pdf_file = tiff_file.substring(0,
> tiff_file.lastIndexOf('.') + 1) + "pdf";
> }
> else {
> pdf_file = tiff_file + ".pdf";
> }
> Document document = null;
> PdfWriter writer = null;
> PdfContentByte cb = null;
> ByteArrayInputStream bais = doc.getContent();
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> try {
> int pages = 0;
> RandomAccessFileOrArray ra = null;
> int comps = 0;
> try {
> ra = new RandomAccessFileOrArray(bais);
> comps = TiffImage.getNumberOfPages(ra);
> }
> catch (Throwable e) {
> System.out.println("Exception in " + tiff_file + " "
> + e.getMessage());
> return null;
> }
> System.out.println("Processing: " + tiff_file);
> for (int c = 0; c < comps; ++c) {
> try {
> Image img = TiffImage.getTiffImage(ra, c + 1);
> if (img != null) {
> System.out.println("page " + (c + 1));
> img.setAbsolutePosition(0, 0);
> if (document == null) {
> document = new Document(new
> Rectangle(img.getWidth(), img.getHeight()));
> writer = PdfWriter.getInstance(document, baos);
> document.open();
> cb = writer.getDirectContent();
> }
> cb.addImage(img);
> document.newPage();
> ++pages;
> }
> }
> catch (Throwable e) {
> System.out.println("Exception " + tiff_file + "
> page " + (c + 1) + " " + e.getMessage());
> }
> }
> ra.close();
> document.close();
>
> IDfId newDocId = doc.saveAsNew(true);
> IDfDocument newDoc = (IDfDocument)
> doc.getSession().getObject(newDocId);
>
> newDoc.setContentEx(baos, "pdf", 0);
> newDoc.setObjectName(pdf_file);
> newDoc.save();
> return newDoc;
> }
> catch (Throwable e) {
> e.printStackTrace();
> return null;
> }
> }
>
>
> Thanks for any help.
>
> Vojta
>
> ______________________________________________________________
> _________
> Message: 3
> Date: Sun, 15 Nov 2009 10:53:20 +0100
> From: 1T3XT info <[email protected]>
> Subject: Re: [iText-questions] PDF generated from TIFF is blank
> To: Post all your questions about iText here
> <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> vojtik wrote:
> > Hi all,
> >
> > i have little problem - i try to generate PDF file from
> large TIFF (zipped TIFF
> > has aprox. 2 MB, unzipped has about 50MB) a the problem is
> that the final PDF
> > file is blank. Document has correct page size, but its
> blank, white page in PDF.
> >
> > Please, do you have any idea what's the reason?
>
> Maybe you've added the image outside the media box.
> Without more info, we can't help you.
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/