Results 1 to 11 of 11

Thread: Plz help me with this problem

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Unhappy 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...

  2. #2
    Hyperactive Member
    Join Date
    Jul 2010
    Location
    UK
    Posts
    288

    Re: Plz help me with this problem

    You could install PrimoPdf as it is free to convert to .pdf as attached.
    Attached Images Attached Images

  3. #3

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    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.

  4. #4
    Hyperactive Member
    Join Date
    Jul 2010
    Location
    UK
    Posts
    288

    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.

  5. #5

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: Plz help me with this problem

    That sucks.... I just cant seem to win here hahaha

  6. #6

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: Plz help me with this problem

    I found this code, but it bombs out at this line:
    vb Code:
    1. 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:
    1. public void GeneratePDFDoc(string strText)
    2.     {
    3.         Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
    4.         FileMode FM = new FileMode();
    5.         FM = FileMode.OpenOrCreate;
    6.         string Pth = "";
    7.         FileStream FS = new FileStream(Server.MapPath(Pth) + "/testing.pdf", FM);
    8.         PdfWriter writer = PdfWriter.GetInstance(doc, FS);
    9.  
    10.         doc.AddDocListener(writer);
    11.         doc.Open();
    12.        
    13.         String htmlText = strText;
    14.         List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(strText), null);
    15.  
    16.         for (int k = 0; k < htmlarraylist.Count; k++)
    17.         {
    18.             doc.Add((IElement)htmlarraylist[k]);
    19.         }
    20.  
    21.         doc.Close();
    22.     }

  7. #7
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Plz help me with this problem

    Quote Originally Posted by tgf-47 View Post
    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.

  8. #8

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: Plz help me with this problem

    Quote Originally Posted by Webskater View Post
    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...

  9. #9
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  10. #10
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  11. #11

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width