  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: Re: Why The image from src of <img > cannot be writteninto pdf file completel | Subject: Re: Why The image from src of <img > cannot be writteninto pdf file completel 2007-10-10 - By Paulo Soares
Back Add the element directly to the document instead of a Paragraph.
Paulo
> -- --Original Message-- -- > From: itext-questions-bounces@(protected) > [mailto:itext-questions-bounces@(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; > > > > /** > > * > > * @(protected) HtmlImageToPdf.java > > * > > * @(protected) Scott > > * > > * @(protected) at 2007-10-10 ??10:24:01 > > * > > */ > > > > public class HtmlImageToPdf > > { > > > > /** > > * @(protected) Scott > > * > > * @(protected) args > > * @(protected) IOException > > * @(protected) 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@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |