I used VS 2010 and the new itextsharp dll (5.0.2.0)
i got the same error - that i cant convert arraylist to generic.
- and just made a generic list of IElements and it worked - i post the code here you see its the same except for the List<IEleme.....
good luck.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Collections;
using System.Text;
using iTextSharp.text.xml;
using iTextSharp.text.html;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//create document
Response.Write(Server.MapPath("."));
Document document = new Document();
try
{
//writer - have our own path!!!
PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + "parsetest.pdf", FileMode.Create));
document.Open();
//html -text - kan be from database or editor too
String htmlText = "<font " +
" color=\"#0000FF\"><b><i>Title One</i></b></font><font " +
" color=\"black\"><br><br>Some text here<br><br><br><font " +
" color=\"#0000FF\"><b><i>Another title here " +
" </i></b></font><font " +
" color=\"black\"><br><br>Text1<br>Text2<br><OL><LI>hi</LI><LI>how are u</LI></OL>";
//make an arraylist ....with STRINGREADER since its no IO reading file...
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
Hello, my post has to do with the code above as I am using it to parse HTML. I have ran into a problem with this code with images.
Using itextSharp to convert an html file to pdf , I am unable to successfully parse an html file on the web server backend even when doing "absolute" or "relative" image referencing itextSharp fails and says "unable to find file c:\my_image.jpg". This is something
I don't understand because I didn't specify c:\my_image.jpg as a path!
Here is a snippet of the HTML which I build in with a Stringbuilder before using it.:
Here is the code which is basically the same as in this thread:
//create document
Response.Write(Server.MapPath("." + @"\Resumes"));
Document document = new Document();
try
{
//writer - have our own path!!!
PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + @"\Resumes\HTML-to-PDF.pdf", FileMode.Create));
document.Open();
//Here is where your HTML source goes................
String htmlText = strSelectUserListBuilder.ToString();
//make an arraylist ....with STRINGREADER since its no IO reading file...
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
//document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
}
catch (Exception exx)
{
Response.Write("<br>____________________________________<br>");
Response.Write("<br>Error: " + exx + "<br>");
Response.Write("<br>StackTrace: " + exx.StackTrace + "<br>");
Response.Write("<br>strPDFDocument: " + strPDFDocument.ToString() + "<br>");
Response.Write("<br>strSelectUserListBuilder: " + strSelectUserListBuilder.ToString() + "<br>");
//Console.Error.WriteLine(exx.StackTrace);
//Console.Error.WriteLine(exx.StackTrace);
}
finally
{
//document.Close();
}
Here is the ERROR that I am getting with the code:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\images\ResumeTopBorderBrown.jpg'.
As you can also see I am using Response.Write at the end to show the display as a test at the end and it shows the images fine in the browser.
the problem is that itextsharp wants to put a image to the pdf with iTextSharp.text.Image and writing only short path in image tag confuses the parser who dont know where the full path is.
i have done this with ordinary pdfs and when you input an image you use this-->
iTextSharp.text.Image.GetInstance(Server.MapPath("/") + "/images/Mypic.jpg"); as an example.
But when you have a html "text" it wants the actual url - (for a reason i dont really know)
so to solve your problem parsing it on the webserver you can add this before your html-string
i have tried it with your code and it works on VS 2008 and itextsharp 5.0.2
hope this will help you out
good luck!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Collections;
using iTextSharp.text.xml;
using iTextSharp.text.html;
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
IElement x = (IElement)htmlarraylist[k];
Response.Write(x.Type.ToString() + "#<br>");
// document.Add((IElement)htmlarraylist[k]);
}
//document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
Hey buddy, if you still haven't figured it out...I tinkered with it and found this solution thanks to intellisense and some good fortune!!!!!!!
Pay close attention to the List creation its a little more drawn out.
This works word for word on my machine using vs 2008 web express
Substitute my path with your machine's own.
Good luck!!!
If you have any examples of barcode creation I'd love to see em!
bullbear
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using CreatePDF;
using iTextSharp.text.html;
using System.Collections;
namespace itextpdf
{
public partial class WebForm1 : System.Web.UI.Page
{
public class barCode : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/pdf";
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(
document, context.Response.OutputStream
);
document.Open();
PdfContentByte cb = writer.DirectContent;
Barcode39 bc39 = new Barcode39();
bc39.Code = "1234";
// comment next line to show barcode text
bc39.Font = null;
document.Add(bc39.CreateImageWithBarcode(cb, null, null));
document.Close();
}
public bool IsReusable {
get { return false; }
}
}
protected void Page_Load(object sender, EventArgs e)
{
CreatePDF.BarcodeHelper bcpd = new CreatePDF.BarcodeHelper();
Document document = new Document();
try {
//writer - have our own path!!! and see you have write permissions...
//!!!!!!!!!!!!!!!!!!!!!!!!!!substitute the asterisks for your file name that you want to create
PdfWriter.GetInstance(document, new FileStream("C:\\Users\\*****\\Documents\\parsetest.pdf", FileMode.Create));
document.Open();
//html -text - kan be from database or editor too
String htmlText="<font " +
" color=\"#0000FF\"><b><i>Title One</i></b></font><font " +
" color=\"black\"><br><br>Some text here<br><br><br><font " +
" color=\"#0000FF\"><b><i>Another title here " +
" </i></b></font><font " +
" color=\"black\"><br><br>Text1<br>Text2<br><OL><LI>hi</LI><LI>how are u</LI></OL>";
//make an arraylist ....with STRINGREADER since its no IO reading file...
//Instead note the way intellisense helped me kinda figure it out!
//this works word for word on vs 2008 web express
//create a list in this fashion
List<iTextSharp.text.IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
May 27, 2010 11:44 PM|LINK
Sorry wrote before checking. Cannot convert array to generic.
I have the opposite if i make a generic list "cannot convert ..arraylist to generic.." if i change
must be the dll version - or are you maybe using VS2010 - framework 4.0? something must be different... i use VS2008 .net 3.5
but did you try to just make it generic list ?
of for example ielements List<IElement> htmlarraylist? then you should be able to iterate with count..
a generic list example
List<string> telling = new List<string>();
telling.Add("How");
telling.Add("Are");
telling.Add("You");
for (int k = 0; k < telling.Count; k++)
{
Response.Write(telling[k]);
}
look what kind of list the parse returns ....i just guess ielements but you may have to cast it . Hope this helps you.
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
May 28, 2010 12:07 AM|LINK
I just had to try out of curiosity...
I used VS 2010 and the new itextsharp dll (5.0.2.0)
i got the same error - that i cant convert arraylist to generic.
- and just made a generic list of IElements and it worked - i post the code here you see its the same except for the List<IEleme.....
good luck.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Collections;
using System.Text;
using iTextSharp.text.xml;
using iTextSharp.text.html;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//create document
Response.Write(Server.MapPath("."));
Document document = new Document();
try
{
//writer - have our own path!!!
PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + "parsetest.pdf", FileMode.Create));
document.Open();
//html -text - kan be from database or editor too
String htmlText = "<font " +
" color=\"#0000FF\"><b><i>Title One</i></b></font><font " +
" color=\"black\"><br><br>Some text here<br><br><br><font " +
" color=\"#0000FF\"><b><i>Another title here " +
" </i></b></font><font " +
" color=\"black\"><br><br>Text1<br>Text2<br><OL><LI>hi</LI><LI>how are u</LI></OL>";
//make an arraylist ....with STRINGREADER since its no IO reading file...
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
}
catch (Exception exx)
{
Console.Error.WriteLine(exx.StackTrace);
Console.Error.WriteLine(exx.Message);
}
}
}
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
May 28, 2010 12:22 AM|LINK
when i got the same error as you did - >
Cannot implicitly convert type 'System.Collections.Generic.List<iTextSharp.text.IElement>' to 'System.Collections.ArrayList'.....
the error also provided the list objects ...
so it was changed- but its good to know anyhow.
belcherman
Member
47 Points
112 Posts
Re: Convert html to pdf using iTextSharp
Aug 27, 2010 02:25 PM|LINK
Hello, my post has to do with the code above as I am using it to parse HTML. I have ran into a problem with this code with images.
Using itextSharp to convert an html file to pdf , I am unable to successfully parse an html file on the web server backend even when doing "absolute" or "relative" image referencing itextSharp fails and says "unable to find file c:\my_image.jpg". This is something I don't understand because I didn't specify c:\my_image.jpg as a path!
Here is a snippet of the HTML which I build in with a Stringbuilder before using it.:
strSelectUserListBuilder.Append("<table border='0' width='600' cellspacing='0' cellpadding='0'>" + strNL.ToString()); strSelectUserListBuilder.Append("<tr>" + strNL.ToString()); strSelectUserListBuilder.Append("<td>" + strNL.ToString()); strSelectUserListBuilder.Append("<p align='center'><img border='0' src='images/ResumeTopBorderBrown.jpg' width='600' height='10'><br>" + strNL.ToString()); strSelectUserListBuilder.Append("<font face='Arial' size='3' color='#876E3A'><b>Consultants<br></b></font>" + strNL.ToString()); strSelectUserListBuilder.Append("<img border='0' src='images/ResumeBottomBorderBrown.jpg' width='600' height='10'>" + strNL.ToString()); strSelectUserListBuilder.Append("</td>" + strNL.ToString()); strSelectUserListBuilder.Append("</tr>" + strNL.ToString()); strSelectUserListBuilder.Append(" <tr><td>" + strNL.ToString()); //RippleEffectStaffList(Status); strSelectUserListBuilder.Append("</td></tr>" + strNL.ToString()); // FOOTER strSelectUserListBuilder.Append("<tr>" + strNL.ToString()); strSelectUserListBuilder.Append("<td>" + strNL.ToString()); strSelectUserListBuilder.Append("<p align='center'><img border='0' src='images/ResumeBottomBorderBrown.jpg' width='600' height='10'>" + strNL.ToString()); strSelectUserListBuilder.Append("</td>" + strNL.ToString()); strSelectUserListBuilder.Append("</tr>" + strNL.ToString()); strSelectUserListBuilder.Append("</table>" + strNL.ToString()); strSelectUserListBuilder.Append("<br><br><br>" + strNL.ToString());Here is the code which is basically the same as in this thread:
//create document Response.Write(Server.MapPath("." + @"\Resumes")); Document document = new Document(); try { //writer - have our own path!!! PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + @"\Resumes\HTML-to-PDF.pdf", FileMode.Create)); document.Open(); //Here is where your HTML source goes................ String htmlText = strSelectUserListBuilder.ToString(); //make an arraylist ....with STRINGREADER since its no IO reading file... List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null); //add the collection to the document for (int k = 0; k < htmlarraylist.Count; k++) { document.Add((IElement)htmlarraylist[k]); } //document.Add(new Paragraph("And the same with indentation....")); // or add the collection to an paragraph // if you add it to an existing non emtpy paragraph it will insert it from //the point youwrite - Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder" mypara.IndentationLeft = 36; mypara.InsertRange(0, htmlarraylist); document.Add(mypara); document.Close(); } catch (Exception exx) { Response.Write("<br>____________________________________<br>"); Response.Write("<br>Error: " + exx + "<br>"); Response.Write("<br>StackTrace: " + exx.StackTrace + "<br>"); Response.Write("<br>strPDFDocument: " + strPDFDocument.ToString() + "<br>"); Response.Write("<br>strSelectUserListBuilder: " + strSelectUserListBuilder.ToString() + "<br>"); //Console.Error.WriteLine(exx.StackTrace); //Console.Error.WriteLine(exx.StackTrace); } finally { //document.Close(); }Here is the ERROR that I am getting with the code:
As you can also see I am using Response.Write at the end to show the display as a test at the end and it shows the images fine in the browser.
What is or could be the issue here?
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
Aug 27, 2010 07:52 PM|LINK
Hi
the problem is that itextsharp wants to put a image to the pdf with iTextSharp.text.Image and writing only short path in image tag confuses the parser who dont know where the full path is.
i have done this with ordinary pdfs and when you input an image you use this-->
iTextSharp.text.Image.GetInstance(Server.MapPath("/") + "/images/Mypic.jpg"); as an example.
But when you have a html "text" it wants the actual url - (for a reason i dont really know)
so to solve your problem parsing it on the webserver you can add this before your html-string
String UrlDirectory = Request.Url.GetLeftPart(UriPartial.Path);
UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/")+1);
that give you the url (http://yoursite/subcat/)
to this you just add the imagetab -->
<img border='0' src='" + UrlDirectory + "/images/ResumeBottomBorderBrown.jpg' width='600' height='10'>
so it can find the picture
so the solution would be like this -->(all code)
i have tried it with your code and it works on VS 2008 and itextsharp 5.0.2
hope this will help you out
good luck!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Collections;
using iTextSharp.text.xml;
using iTextSharp.text.html;
public partial class Default3 : System.Web.UI.Page
{
String strSelectUserListBuilder = "";
protected void Page_Load(object sender, EventArgs e)
{
//create document
//Response.Write(Server.MapPath("."));
Document document = new Document();
try
{
String UrlDirectory = Request.Url.GetLeftPart(UriPartial.Path);
UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/")+1);
Response.Write(UrlDirectory);
//writer - have our own path!!!
PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + @"HTML-to-PDF.pdf", FileMode.Create));
document.Open();
strSelectUserListBuilder = "<table border='0' width='600' cellspacing='0' cellpadding='0'>" +
"<tr>" +
"<td>" +
"<p align='center'><img border='0' src='" + UrlDirectory + "/images/ResumeBottomBorderBrown.jpg' width='600' height='10'><br>" +
"<font face='Arial' size='3' color='#876E3A'><b>Consultants<br></b></font>" +
"<img border='0' src='" + UrlDirectory + "images/ResumeBottomBorderBrown.jpg' width='600' height='10'>" +
"</td>" +
"</tr>" +
" <tr><td>" +
"</td></tr>" +
// FOOTER
"<tr>" +
"<td>" +
"<p align='center'><img border='0' src='" + UrlDirectory + "images/ResumeBottomBorderBrown.jpg' width='600' height='10'>" +
"</td>" +
"</tr>" +
"</table>" +
"<br><br><br>";
//Here is where your HTML source goes................
String htmlText = strSelectUserListBuilder.ToString();
//make an arraylist ....with STRINGREADER since its no IO reading file...
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
IElement x = (IElement)htmlarraylist[k];
Response.Write(x.Type.ToString() + "#<br>");
// document.Add((IElement)htmlarraylist[k]);
}
//document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
}
catch (Exception exx)
{
Response.Write("<br>____________________________________<br>");
Response.Write("<br>Error: " + exx + "<br>");
Response.Write("<br>StackTrace: " + exx.StackTrace + "<br>");
Response.Write("<br>strSelectUserListBuilder: " + strSelectUserListBuilder.ToString() + "<br>");
//Console.Error.WriteLine(exx.StackTrace);
//Console.Error.WriteLine(exx.StackTrace);
}
finally
{
//document.Close();
}
}
}
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
Aug 27, 2010 08:15 PM|LINK
ps
ofcourse the correct path is + UrlDirectory + "images/ as in the 2 last but it seems to work with + UrlDirectory + "/images/ too...
tamannashah1...
Member
2 Points
1 Post
Re: Convert html to pdf using iTextSharp
Nov 12, 2010 08:19 AM|LINK
hello,
i tried this but this also gives error.
Error 29 The non-generic type 'iTextSharp.text.List' cannot be used with type arguments .
plz help me!!
its really urgent.
thanks in advance.
.netdevelop
Member
20 Points
10 Posts
Re: Convert html to pdf using iTextSharp
Nov 12, 2010 10:17 AM|LINK
Hi
Which version of itextsharp do you use?
Look in example before when i used -->
ArrayList htmlarraylist = iTextSharp.text.html.simpleparser ...itextsharp version 4.1.6.0 --> instead of
List<IElement> htmlarraylist = iTextSharp.text.......itextsharp dll (5.0.2.0)
It was different returns on the html.simpleparser.Maybe they changed it again ?(if you use a newer version.)
If you use a newer version download one of the older and see if it works with version/code.
bullbear
Member
2 Points
2 Posts
Re: Convert html to pdf using iTextSharp
Dec 26, 2010 10:33 PM|LINK
Hey buddy, if you still haven't figured it out...I tinkered with it and found this solution thanks to intellisense and some good fortune!!!!!!!
Pay close attention to the List creation its a little more drawn out.
This works word for word on my machine using vs 2008 web express
Substitute my path with your machine's own.
Good luck!!!
If you have any examples of barcode creation I'd love to see em!
bullbear
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using CreatePDF;
using iTextSharp.text.html;
using System.Collections;
namespace itextpdf
{
public partial class WebForm1 : System.Web.UI.Page
{
public class barCode : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/pdf";
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(
document, context.Response.OutputStream
);
document.Open();
PdfContentByte cb = writer.DirectContent;
Barcode39 bc39 = new Barcode39();
bc39.Code = "1234";
// comment next line to show barcode text
bc39.Font = null;
document.Add(bc39.CreateImageWithBarcode(cb, null, null));
document.Close();
}
public bool IsReusable {
get { return false; }
}
}
protected void Page_Load(object sender, EventArgs e)
{
CreatePDF.BarcodeHelper bcpd = new CreatePDF.BarcodeHelper();
Document document = new Document();
try {
//writer - have our own path!!! and see you have write permissions...
//!!!!!!!!!!!!!!!!!!!!!!!!!!substitute the asterisks for your file name that you want to create
PdfWriter.GetInstance(document, new FileStream("C:\\Users\\*****\\Documents\\parsetest.pdf", FileMode.Create));
document.Open();
//html -text - kan be from database or editor too
String htmlText="<font " +
" color=\"#0000FF\"><b><i>Title One</i></b></font><font " +
" color=\"black\"><br><br>Some text here<br><br><br><font " +
" color=\"#0000FF\"><b><i>Another title here " +
" </i></b></font><font " +
" color=\"black\"><br><br>Text1<br>Text2<br><OL><LI>hi</LI><LI>how are u</LI></OL>";
//make an arraylist ....with STRINGREADER since its no IO reading file...
//Instead note the way intellisense helped me kinda figure it out!
//this works word for word on vs 2008 web express
//create a list in this fashion
List<iTextSharp.text.IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
}
catch (Exception exx) {
Console.Error.WriteLine(exx.StackTrace);
Console.Error.WriteLine(exx.Message);
}
}
}
}
PDF Document dymanic "C#" iTextSharp
inderjeetsin...
Member
105 Points
163 Posts
Re: Convert html to pdf using iTextSharp
Aug 05, 2011 06:59 AM|LINK
can i add header and footer with each pdf page after conversion, if i can how is this possible..
thanks and regards
Inderjeet Singh