471,089 Members | 1,115 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

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.binarywrite method but i cnat print the pdf files
Nov 3 '10 #1
2 8590
3,406 Expert 2GB
in the asp insights section there is an article on saving files from uploads, that has everything you will need.

Nov 3 '10 #2
You'll need to set Response.ContentType to "application/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...

Expand|Select|Wrap|Line Numbers
  1. <%@ Import Namespace="WebSupergoo.ABCpdf7" %>
  2. <%
  3. Doc theDoc = new Doc();
  4. theDoc.FontSize = 96;
  5. theDoc.AddText("Hello World");
  6. byte[] theData = theDoc.GetData();
  7. theDoc.Clear();
  9. Response.ContentType = "application/pdf";
  10. Response.AddHeader("content-length", theData.Length.ToString());
  11. Response.AddHeader("content-disposition", "attachment; filename=ExampleSite.pdf");
  12. Response.BinaryWrite(theData);
  13. Response.End();
  14. %>
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...
Nov 11 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Alec MacLean | last post: by
2 posts views Thread by =?Utf-8?B?am9obmFicmFoYW0xMDE=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.