Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error while converting from ASP . NET to PDf

Error while converting from ASP . NET to PDf

Scheduled Pinned Locked Moved ASP.NET
helphtmlsysadminquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kvsreedhar
    wrote on last edited by
    #1

    Anyone please help me I have a program which converts a .txt file to PDF file . I am getting the following error while running the program Error 'C:\Documents and Settings\........' is not a valid virtual path in ASP . NET I give my Code below ... code in button Click --------------------------- String fileName = ""; String strText = ""; // create instance of the PDF manager IPdfManager objPDF = new PdfManager(); // Create new document IPdfDocument objDoc = objPDF.CreateDocument(Missing.Value); // Add a page to document. Pages are intentionally small to demonstrate text spanning IPdfPage objPage = objDoc.Pages.Add(300, 300, Missing.Value); // use Arial font IPdfFont objFont = objDoc.Fonts["Arial", Missing.Value]; fileName = Path.GetFullPath(fileUpload1.PostedFile.FileName); try { strText = objPDF.LoadTextFromFile(Server.MapPath(fileName)); } catch (Exception ex) { Response.Write("error is "+ex.Message); } // Parameters: X, Y of upper-left corner of text box, Height, Width IPdfParam objParam = objPDF.CreateParam("x=10; y=290; width=280; height=280; html=true"); while (strText.Length > 0) { // DrawText returns the number of characters that fit in the box allocated. int nCharsPrinted = objPage.Canvas.DrawText(strText, objParam, objFont); // HTML tag generated by DrawText to reflect current font state String strHtmlTag = objPage.Canvas.HtmlTag; // The entire string printed? Exit loop. if (nCharsPrinted == strText.Length) break; // Otherwise print remaining text on next page objPage = objPage.NextPage; strText = strHtmlTag + strText.Substring(nCharsPrinted); } // Save document, the Save method returns generated file name String strFilename = objDoc.Save(Server.MapPath("mask.pdf"), false); lblResult.Text = "Success! Download your PDF file <A HREF=" + strFilename + ">here</A>"; ---------------------------- :rose: Thanks in Advance :rose:

    Kovuru Sreedhar

    A 1 Reply Last reply
    0
    • K kvsreedhar

      Anyone please help me I have a program which converts a .txt file to PDF file . I am getting the following error while running the program Error 'C:\Documents and Settings\........' is not a valid virtual path in ASP . NET I give my Code below ... code in button Click --------------------------- String fileName = ""; String strText = ""; // create instance of the PDF manager IPdfManager objPDF = new PdfManager(); // Create new document IPdfDocument objDoc = objPDF.CreateDocument(Missing.Value); // Add a page to document. Pages are intentionally small to demonstrate text spanning IPdfPage objPage = objDoc.Pages.Add(300, 300, Missing.Value); // use Arial font IPdfFont objFont = objDoc.Fonts["Arial", Missing.Value]; fileName = Path.GetFullPath(fileUpload1.PostedFile.FileName); try { strText = objPDF.LoadTextFromFile(Server.MapPath(fileName)); } catch (Exception ex) { Response.Write("error is "+ex.Message); } // Parameters: X, Y of upper-left corner of text box, Height, Width IPdfParam objParam = objPDF.CreateParam("x=10; y=290; width=280; height=280; html=true"); while (strText.Length > 0) { // DrawText returns the number of characters that fit in the box allocated. int nCharsPrinted = objPage.Canvas.DrawText(strText, objParam, objFont); // HTML tag generated by DrawText to reflect current font state String strHtmlTag = objPage.Canvas.HtmlTag; // The entire string printed? Exit loop. if (nCharsPrinted == strText.Length) break; // Otherwise print remaining text on next page objPage = objPage.NextPage; strText = strHtmlTag + strText.Substring(nCharsPrinted); } // Save document, the Save method returns generated file name String strFilename = objDoc.Save(Server.MapPath("mask.pdf"), false); lblResult.Text = "Success! Download your PDF file <A HREF=" + strFilename + ">here</A>"; ---------------------------- :rose: Thanks in Advance :rose:

      Kovuru Sreedhar

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      kvsreedhar wrote:

      Error 'C:\Documents and Settings\........' is not a valid virtual path in ASP . NET

      Says it all really. ASP.NET cannot access your C: drive. It can only access its own virtual directory.

      Bob Ashfield Consultants Ltd

      K 1 Reply Last reply
      0
      • A Ashfield

        kvsreedhar wrote:

        Error 'C:\Documents and Settings\........' is not a valid virtual path in ASP . NET

        Says it all really. ASP.NET cannot access your C: drive. It can only access its own virtual directory.

        Bob Ashfield Consultants Ltd

        K Offline
        K Offline
        kvsreedhar
        wrote on last edited by
        #3

        thankyou for your consideration to my query may please suggest a solution so that I can access from any drive Thanks in Advance

        Kovuru Sreedhar

        T 1 Reply Last reply
        0
        • K kvsreedhar

          thankyou for your consideration to my query may please suggest a solution so that I can access from any drive Thanks in Advance

          Kovuru Sreedhar

          T Offline
          T Offline
          Tamer Oz
          wrote on last edited by
          #4

          Give permissions to IISWPG user group. Notice that it can cause security leak.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups