Plz help me with this problem
I've been all over the web with this issue and I just can't get anything to work.
I've been at this for over a week now....
I have a webpage (clientoverview.aspx).
I need something to convert that page to a .PDF file and save it on my pc.
I need the PDF to look like the webpage (css and all).
I tried iTextSharp, but can't get it to work. Can anybody please post a "TESTED" script or c# code to do this?
We can't buy any products to do this (Client doesn't want to do it like that)...
Bummer... :eek: :( :eek2:
1 Attachment(s)
Re: Plz help me with this problem
You could install PrimoPdf as it is free to convert to .pdf as attached.
Re: Plz help me with this problem
Do I have to install this app on all the workstations that will be using the system?
The goal is to give the user the ability to export to pdf without having to install or download something first.
Re: Plz help me with this problem
Yes - with that you would need to install it on the client.
There is ASPPDF which I have never used that I believe does what you are after, the downside being, I also believe you have to pay for it.
Re: Plz help me with this problem
That sucks.... I just cant seem to win here hahaha
Re: Plz help me with this problem
I found this code, but it bombs out at this line:
vb Code:
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(strText), null);
with this message:
Code:
Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Paragraph'.
This is the code:
vb Code:
public void GeneratePDFDoc(string strText)
{
Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
FileMode FM = new FileMode();
FM = FileMode.OpenOrCreate;
string Pth = "";
FileStream FS = new FileStream(Server.MapPath(Pth) + "/testing.pdf", FM);
PdfWriter writer = PdfWriter.GetInstance(doc, FS);
doc.AddDocListener(writer);
doc.Open();
String htmlText = strText;
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(strText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
{
doc.Add((IElement)htmlarraylist[k]);
}
doc.Close();
}
Re: Plz help me with this problem
Quote:
Originally Posted by
tgf-47
That sucks.... I just cant seem to win here hahaha
I'm curious - why are you expecting someone to provide you with free code. I tried out the EVO pdf creator a while ago. It seems good to me - works well and is easy to install and at a very modest cost.
Re: Plz help me with this problem
Quote:
Originally Posted by
Webskater
I'm curious - why are you expecting someone to provide you with free code. I tried out the EVO pdf creator a while ago. It seems good to me - works well and is easy to install and at a very modest cost.
Just following orders from uptop...
Re: Plz help me with this problem
tgf-47,
Please don't post the same question in multiple threads, you are already asking about the exception that you are getting in your other thread.
I am going to close that thread, and continue the discussion here.
Gary
Re: Plz help me with this problem
From the above code sample, please provide information about which line is throwing the error, and also provide a sample of the text that you are trying to turn into a PDF.
Gary
Re: Plz help me with this problem
Hi Gary, Sorry about the multiple threads. <Got a bit anxious with the deadline approaching. My Bad...
We decided to can the PDF generation and just go the MSReports route. The client can save to excel or PDF from there, so it still complies to the spec.
Thanks for all the help guys. I will sort out my problem when I do not have as much work on my shoulders. Will post final code in this thread.