How to print the pdf file using binarywrite method in asp?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rakulkumar

    #1

    How to print the pdf file using binarywrite method in asp?

    how can i print the pdf file using binarywrite method in asp.i can print the text file using Response.binary write method but i cnat print the pdf files
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    in the asp insights section there is an article on saving files from uploads, that has everything you will need.

    Jared

    Comment

    • AdobeGuru
      New Member
      • Nov 2010
      • 1

      #3
      You'll need to set Response.Conten tType to "applicatio n/pdf".

      You may also need to supply a dummy filename and set the "content-disposition" header to "attachment ", or "inline", depending on the desired behavior...

      Code:
      <%@ Import Namespace="WebSupergoo.ABCpdf7" %>
      <%
      Doc theDoc = new Doc();
      theDoc.FontSize = 96;
      theDoc.AddText("Hello World");
      byte[] theData = theDoc.GetData();
      theDoc.Clear();
      
      Response.ContentType = "application/pdf";
      Response.AddHeader("content-length", theData.Length.ToString());
      Response.AddHeader("content-disposition", "attachment; filename=ExampleSite.pdf");
      Response.BinaryWrite(theData);
      Response.End();
      %>
      The above ASP example is written in CSharp and makes use of the ABCpdf.NET component. I've done this to show how easy it can be to generate a PDF dynamically from within ASP (although any other PDF component should do). Otherwise, trying to manually construct a PDF from scratch is really hard work.

      A few PDF components...

      Comment

      Working...