  | 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 bewritteninto pdf file completely | Subject: Re: Why The image from src of <img > cannot bewritteninto pdf file completely 2007-10-10 - By Scott WoodEasy
Back 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: 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/
<HTML><HEAD><TITLE>Mail</TITLE> <META content="KsDHTMLEDLib.ocx, FreeWare HTML Editor 1.164.2, ?Kurt Senfer" name=GENERATOR> <META http-equiv=Content-Type content="text/html; charset=GB2312"></HEAD> <BODY style="FONT-SIZE: 9pt; FONT-FAMILY: ??" leftMargin=5 topMargin=5 #ffffff> <DIV><!--AID_SENDTO_BEGIN--><FONT face="Lucida Console" size=3>Thanks for your reply,Paulo.</FONT></DIV> <DIV><FONT face="Lucida Console" size=3></FONT> </DIV> <DIV><FONT face="Lucida Console" size=3>But again it failed to generate the image completely.</FONT></DIV> <DIV><FONT face="Lucida Console" size=3></FONT> </DIV> <DIV><FONT face="Lucida Console" size=3>Is it a bug?</FONT></DIV> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal">-- -- Original Message -- -- </DIV> <DIV style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; BACKGROUND: #e4e4e4; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal; font-color: black"><B>From: </B><A href="mailto:psoares@(protected)">Paulo Soares</A> </DIV> <DIV style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal"><B>To: </B><A href="mailto:itext-questions@(protected)">Post all your questions about iText here</A> </DIV> <DIV style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal"><B>Sent: </B>2007-10-10, 18:27:38</DIV> <DIV style="FONT-WEIGHT: normal; FONT-SIZE: 9pt; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal"><B>Subject: </B>Re: [iText-questions] Why The image from src of <IMG> cannot bewritteninto pdf file completely?</DIV> <DIV><BR></DIV> <DIV></DIV> <DIV></DIV> <DIV> <DIV>Add the element directly to the document instead of a Paragraph.<BR><BR>Paulo <BR><BR>> -- --Original Message-- --<BR>> From: <A href="mailto: itext-questions-bounces@(protected)">itext-questions -bounces@(protected)</A> <BR>> [mailto:<A href="mailto: itext-questions-bounces@(protected)">itext-questions -bounces@(protected)</A>] On <BR>> Behalf Of Scott<BR>> Sent: Wednesday, October 10, 2007 3:54 AM<BR>> To: itext-questions<BR>> Subject: [iText-questions] Why The image from src of <img> <BR>> cannot be writteninto pdf file completely?<BR>> <BR>> Hello Everyone<BR>> <BR>> When I was using HTMLWorker to parse some HTML piece into a <BR>> pdf file,I found a problem.<BR>> The image from src of <img> cannot be written into pdf file <BR>> completely,but a part of the image instead.<BR>> Below is my code,and the generated pdf file attached.<BR>> Anyone knows why?<BR>> Thank you so much?<BR>> <BR>> <BR>> <BR>> <BR>> import java.io.FileNotFoundException;<BR>> <BR>> import java.io.FileOutputStream;<BR>> <BR>> import java.io.FileReader;<BR>> <BR>> import java.io.IOException;<BR>> <BR>> import java.io.StringReader;<BR>> <BR>> import java.util.ArrayList;<BR>> <BR>> <BR>> <BR>> import com.lowagie.text.Document;<BR>> <BR>> import com.lowagie.text.DocumentException;<BR>> <BR>> import com.lowagie.text.Element;<BR>> <BR>> import com.lowagie.text.Paragraph;<BR>> <BR>> import com.lowagie.text.html.HtmlWriter;<BR>> <BR>> import com.lowagie.text.html.simpleparser.HTMLWorker;<BR>> <BR>> import com.lowagie.text.pdf.PdfWriter;<BR>> <BR>> <BR>> <BR>> /**<BR>> ; <BR>> * <BR>> <BR>> * @(protected) HtmlImageToPdf.java<BR>> <BR>> * <BR>> <BR>> * @(protected) Scott<BR>> <BR>> * <BR>> <BR>> * @(protected) at 2007-10-10 ??10:24:01<BR>> <BR>> * <BR>> <BR>> */<BR>> <BR>> <BR>> <BR>> public class HtmlImageToPdf<BR>> <BR>> {<BR>> <BR>> <BR>> <BR>> /**<BR>> <BR>> * @(protected) Scott<BR>> <BR>> * <BR>> <BR>> * @(protected) args<BR>> <BR>> * @(protected) IOException<BR>> <BR>> * @(protected) DocumentException<BR>> <BR>> */<BR>> <BR>> public static void main(String[] args) throws IOException,<BR>> <BR>> DocumentException<BR>> <BR>> {<BR>> <BR>> StringBuffer HtmlPiece = new StringBuffer();<BR>> <BR>> HtmlPiece.append("<body>");<BR>> <BR>> HtmlPiece.append("<h1>Hello Beauty!</h1><br />");<BR>> <BR>> HtmlPiece.append("<img src=?"F:??1.jpg?">");<BR>> <BR>> HtmlPiece.append("</body>");<BR>> <BR>> <BR>> <BR>> Document doc = new Document();<BR>> <BR>> PdfWriter.getInstance(doc, new FileOutputStream(<BR>> <BR>> "D:??HtmlImageToPdf.pdf"));<BR>> <BR>> Paragraph para = new Paragraph();<BR>> <BR>> doc.open();<BR>> <BR>> new HTMLWorker(doc);<BR>> <BR>> ArrayList p = HTMLWorker.parseToList(new <BR>> StringReader(HtmlPiece.toString()), null);<BR>> <BR>> for (int k = 0; k < p.size(); ++k)<BR>> <BR>> ; {<BR>> <BR>> para.add((Element) p.get(k));<BR>> <BR>> }<BR>> <BR>> <BR>> <BR>> doc.add(para);<BR>> <BR>> doc.close();<BR>> <BR>> System.out.println("??");<BR>> <BR>> <BR>> <BR>> }<BR>> <BR>> <BR>> <BR>> }<BR>> <BR>> <BR>> <BR>> <BR><BR><BR>Aviso Legal:<BR>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. <BR><BR>Disclaimer:<BR>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.<BR><BR>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --- -- ---- ----<BR>This SF.net email is sponsored by: Splunk Inc.<BR>Still grepping through log files to find problems? Stop.<BR>Now Search log events and configuration files using AJAX and a browser.<BR>Download your FREE copy of Splunk now >> <A href="http://get.splunk.com/">http://get.splunk.com/</A><BR>__ ____ ____ ____ __ ____ ____ ____ ____ ____ __<BR>iText-questions mailing list<BR><A href="mailto: iText-questions@(protected)">iText-questions@(protected) .sourceforge.net</A><BR><A href="https://lists.sourceforge.net/lists/listinfo/itext-questions">https:/ /lists.sourceforge.net/lists/listinfo/itext-questions</A><BR>Buy the iText book: <A href="http://itext.ugent.be/itext-in-action/">http://itext.ugent.be/itext-in -action/</A><BR></DIV></DIV></BLOCKQUOTE></BODY></HTML>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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/
|
|
 |