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. General Programming
  3. C#
  4. Export PDF file in C#

Export PDF file in C#

Scheduled Pinned Locked Moved C#
csharpadobearchitecturehelp
2 Posts 2 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.
  • R Offline
    R Offline
    r aa j
    wrote on last edited by
    #1

    hi all, I want export the pdf file.and I am using following code.In my system .But an error is displaying like adobe readercould not open 'down.pdf' because it is either not a supported file type or because the file has been damaged... DataSet Ds = FillGrid2(sessionvalue, cid, cmid, crid, pid, sdate, edate); Response.Clear(); Response.AppendHeader("Content-Type", "application/pdf"); Response.AppendHeader("Content-disposition", "attachment; filename=Download.pdf"); string str = "<table style='border:1px solid #000000;'>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Client: </b>" + client + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Campaign: </b>" + campaign + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Report Summary</b>" + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td>" + "Type" + "</td>"; str += "<td>" + "Impression" + "</td>"; str += "<td>" + "Clicks" + "</td>"; str += "<td>" + "Start Date" + "</td>"; str += "<td>" + "End Date" + "</td>"; str += "</tr>"; for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { str += "<tr style='border:1px solid #000000;'>"; for (int j = 0; j < Ds.Tables[0].Columns.Count; j++) { str += "<td>" + Ds.Tables[0].Rows[i][j].ToString() + "</td>"; } str += "</tr>"; } str += "</table>"; Response.Write(str); If anybody knows please reply me.. thanks...

    Raaj

    B 1 Reply Last reply
    0
    • R r aa j

      hi all, I want export the pdf file.and I am using following code.In my system .But an error is displaying like adobe readercould not open 'down.pdf' because it is either not a supported file type or because the file has been damaged... DataSet Ds = FillGrid2(sessionvalue, cid, cmid, crid, pid, sdate, edate); Response.Clear(); Response.AppendHeader("Content-Type", "application/pdf"); Response.AppendHeader("Content-disposition", "attachment; filename=Download.pdf"); string str = "<table style='border:1px solid #000000;'>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Client: </b>" + client + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Campaign: </b>" + campaign + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td colspan='5'>" + "<b>Report Summary</b>" + "</td>"; str += "</tr>"; str += "<tr>"; str += "<td>" + "Type" + "</td>"; str += "<td>" + "Impression" + "</td>"; str += "<td>" + "Clicks" + "</td>"; str += "<td>" + "Start Date" + "</td>"; str += "<td>" + "End Date" + "</td>"; str += "</tr>"; for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { str += "<tr style='border:1px solid #000000;'>"; for (int j = 0; j < Ds.Tables[0].Columns.Count; j++) { str += "<td>" + Ds.Tables[0].Rows[i][j].ToString() + "</td>"; } str += "</tr>"; } str += "</table>"; Response.Write(str); If anybody knows please reply me.. thanks...

      Raaj

      B Offline
      B Offline
      blackjack2150
      wrote on last edited by
      #2

      Maybe I misunderstood, but are you assuming that writing HTML code and setting the content-type to 'application/pdf' will give you a valid PDF file? That's totally wrong!! You should use a PDF library for that. I recommend PDF Sharp, which is free. Also, use the StingBuilder class if you want to append characters to an existing string. It's far more efficient.

      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