Thanks for your reply,Paulo.

But again it failed to generate the image completely.

Is it a bug?
----- Original Message ----- 
From: Paulo Soares 
To: Post all your questions about iText here 
Sent: 2007-10-10, 18:27:38
Subject: Re: [iText-questions] Why The image from src of  cannot bewritteninto 
pdf file completely?


Add the element directly to the document instead of a Paragraph.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Scott
> Sent: Wednesday, October 10, 2007 3:54 AM
> To: itext-questions
> Subject: [iText-questions] Why The image from src of <img> 
> cannot be writteninto pdf file completely?
> 
> Hello Everyone
> 
> When I was using HTMLWorker to parse some HTML piece into a 
> pdf file,I found a problem.
> The image from src of <img> cannot be written into pdf file 
> completely,but a part of the image instead.
> Below is my code,and the generated pdf file attached.
> Anyone knows why?
> Thank you so much!
> 
> 
> 
> 
> import java.io.FileNotFoundException;
> 
> import java.io.FileOutputStream;
> 
> import java.io.FileReader;
> 
> import java.io.IOException;
> 
> import java.io.StringReader;
> 
> import java.util.ArrayList;
> 
> 
> 
> import com.lowagie.text.Document;
> 
> import com.lowagie.text.DocumentException;
> 
> import com.lowagie.text.Element;
> 
> import com.lowagie.text.Paragraph;
> 
> import com.lowagie.text.html.HtmlWriter;
> 
> import com.lowagie.text.html.simpleparser.HTMLWorker;
> 
> import com.lowagie.text.pdf.PdfWriter;
> 
> 
> 
> /**
> 
> * 
> 
> * @file HtmlImageToPdf.java
> 
> * 
> 
> * @author Scott
> 
> * 
> 
> * @created at 2007-10-10 上午10:24:01
> 
> * 
> 
> */
> 
> 
> 
> public class HtmlImageToPdf
> 
> {
> 
> 
> 
> /**
> 
> * @author Scott
> 
> * 
> 
> * @param args
> 
> * @throws IOException
> 
> * @throws DocumentException
> 
> */
> 
> public static void main(String[] args) throws IOException,
> 
> DocumentException
> 
> {
> 
> StringBuffer HtmlPiece = new StringBuffer();
> 
> HtmlPiece.append("<body>");
> 
> HtmlPiece.append("<h1>Hello Beauty!</h1><br />");
> 
> HtmlPiece.append("<img src=¥"F:¥¥1.jpg¥">");
> 
> HtmlPiece.append("</body>");
> 
> 
> 
> Document doc = new Document();
> 
> PdfWriter.getInstance(doc, new FileOutputStream(
> 
> "D:¥¥HtmlImageToPdf.pdf"));
> 
> Paragraph para = new Paragraph();
> 
> doc.open();
> 
> new HTMLWorker(doc);
> 
> ArrayList p = HTMLWorker.parseToList(new 
> StringReader(HtmlPiece.toString()), null);
> 
> for (int k = 0; k < p.size(); ++k)
> 
> {
> 
> para.add((Element) p.get(k));
> 
> }
> 
> 
> 
> doc.add(para);
> 
> doc.close();
> 
> System.out.println("完成");
> 
> 
> 
> }
> 
> 
> 
> }
> 
> 
> 
> 


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.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to