473,411 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 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 8873
jhardman
3,406 Expert 2GB
in the asp insights section there is an article on saving files from uploads, that has everything you will need.

Jared
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();
  8.  
  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. %>
  15.  
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

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

Similar topics

3
by: CD | last post by:
Hi, I am getting a problem using the following piece of code: Dim strfile As Object Set strfile = FSO.OpenTextFile(stFilePath, 1) Do While Not strfile.AtEndOfStream strtext =...
6
by: Alec MacLean | last post by:
Hi, I've created a small application for our company extranet (staff bulletins) that outputs a list of links to PDF's that are stored in a SQL table. The user clicks a link and the PDF is...
2
by: asenthil | last post by:
Hai... i'm triying to open a file in read mode using the following method.. HFILE hFile; hFile=OpenFile("D:\ss.doc",lpReOpenBuff,OF_READ); i cant undestand what is the 2nd parameter is... ...
2
by: =?Utf-8?B?am9obmFicmFoYW0xMDE=?= | last post by:
hello, I'm trying to write a some text to a text file using WriteAllText method. This method works fine but I don't understand how can I use format specifiers to format the text as we use in C i.e...
0
by: 2pt2mill | last post by:
I have been using SharpZipLib for over a year with no problems, but it doesn't support files zipped using compression method 6 (Imploding). This seems to be an older method of compression utilized...
0
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
0
by: newUser1234 | last post by:
I'm trying to read and write from an excel file using this method..My application can read the excel file without problems but doesn't write anything to the file i want it to write. I've also tried...
0
by: Christian Heimes | last post by:
dudeja.rajat@gmail.com wrote: Try %% :) Christian
1
by: raghudr | last post by:
Hi all, I am parsing an .xml file.My main intention is to retrieve the field value:- "Name Value" which is "rag" and store it in a List. Fot that i wrote code like this: //i am using...
0
by: mraja1977 | last post by:
Hi All, I am writting/opening different types file data to the browser by using following code in c#. for all type of files there wont be any problem, but in case of html file, when i tries...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.