Hi
I try to generate a PDF File with iTextSharp from a HTML - Text and Table
content works perfect. Images are positioned wrong - the image flows not in
the text at the right position! I expect first the h1 part and than the
image - I get the H1 part and the Image is in the background and the start
position is at the right position (after h1) but the image grows out of the
page start.
Have you an example which fixes the image flow?
My code is:
//Document is inbuilt class, available in iTextSharp
MemoryStream file = new MemoryStream();
Document document = new Document(this.PageSize);
PdfWriter writer = PdfWriter.GetInstance(document, file);
document.Open();
document.NewPage();
//generate this page of text
MemoryStream output = new MemoryStream();
StreamWriter html = new StreamWriter(output, Encoding.UTF8);
//get the page output
html.Write<html><body><h1>Title</h1><img
src=\"http://www.ricardo.ch/ImgWeb/2/V3/header/logo.gif\"
/></body></html>");
html.Close();
html.Dispose();
//read the created stream
MemoryStream generate = new MemoryStream(output.ToArray());
StreamReader reader = new StreamReader(generate);
foreach (object item in HTMLWorker.ParseToList(reader,
this._Styles)) {
document.Add((IElement)item);
}
//cleanup these streams
html.Dispose();
reader.Dispose();
output.Dispose();
generate.Dispose();
//after rendering
if (this.AfterRender is RenderEvent) {
this.AfterRender(writer, document);
}
//return the rendered PDF
document.Close();
return file.ToArray();
Kind regards
Manfred
Manfred Jehle
Rigistrasse 158
CH-6340 Baar
Switzerland
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/