473,396 Members | 2,018 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,396 software developers and data experts.

pdf conversion using c# and asp.net

Hi,
I want to convert my html page into pdf using c# in codebehind and asp.net. Iis there any assembly or something in .net to do so. I tried itextsharp library but it is saving the pdf file in hard drive I dont want to do in this way, actually am generating reports for my web project thats why i dont want them to be saved in hard drive. Is it possible to generate pdf file without saving? just display the report in browsers. Please help me i need it very urgently.

Thanks
Nov 18 '05 #1
5 1393
sorry I don't know of a solution but if you need it urgently go with the
best thing you have

use itextstarp to generate the PDF to a temporary file (make sure you give
the file a unique name), then read the file from the disk, stream it to the
user and delete it. Don't worry about the performance of saving and
re-reading the file - it won't be noticeable

Andy
"dawood" <da****@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
Hi,
I want to convert my html page into pdf using c# in codebehind and asp.net. Iis there any assembly or something in .net to do so. I tried
itextsharp library but it is saving the pdf file in hard drive I dont want
to do in this way, actually am generating reports for my web project thats
why i dont want them to be saved in hard drive. Is it possible to generate
pdf file without saving? just display the report in browsers. Please help me
i need it very urgently.
Thanks

Nov 18 '05 #2
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
sorry I don't know of a solution but if you need it urgently go with the
best thing you have

use itextstarp to generate the PDF to a temporary file (make sure you give
the file a unique name), then read the file from the disk, stream it to the user and delete it. Don't worry about the performance of saving and
re-reading the file - it won't be noticeable


I agree. I recently worked on a project which had this functionality and,
because of the IE / PDF bug
(http://www.google.com/search?sourcei...TF-8&q=IE+PDF+
bug), this was the only way to guarantee that it would work.
Nov 18 '05 #3


"Mark Rae" wrote:
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
sorry I don't know of a solution but if you need it urgently go with the
best thing you have

use itextstarp to generate the PDF to a temporary file (make sure you give
the file a unique name), then read the file from the disk, stream it to

the
user and delete it. Don't worry about the performance of saving and
re-reading the file - it won't be noticeable



if i delete the file then will it displayed to the user for printing or so? and how to stream the file pls give example.

Nov 18 '05 #4

"dawood" <da****@discussions.microsoft.com> wrote in message
news:BF**********************************@microsof t.com...


"Mark Rae" wrote:
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
sorry I don't know of a solution but if you need it urgently go with the best thing you have

use itextstarp to generate the PDF to a temporary file (make sure you give the file a unique name), then read the file from the disk, stream it
to the
user and delete it. Don't worry about the performance of saving and
re-reading the file - it won't be noticeable


if i delete the file then will it displayed to the user for printing or

so? and how to stream the file pls give example.

in an aspx file, do this:

Byte[] fileContents;
..read temp file from disk into fileContents
..delete temp file
Response.ContentType = "application/pdf"
Response.BinaryWrite(fileContents);

there may be some other way with streams that doesn't involve reading the
whole file into memory, but this is just an example I had handy
Nov 18 '05 #5
You can use itextsharp to generate the .pdf files and send them to the browser. The example is in VB.Net, but it can easily be ported to C#.
Dim m As New System.IO.MemoryStream

Dim document As ItextSharp.text.Document = New Document(PageSize.LETTER)
Dim writer as iTextSharp.text.pdf.pdfWriter = iTextSharp.text.pdf.PdfWriter.getInstance(document , m)

Try
document.Open()

'... manipulate the document here

document.Close()
Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer.Length)
Response.End()
Catch(ex as Exception)
Throw ex
End Try

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Aaron Queenan | last post by:
Given the classes: class Class { public static implicit operator int(Class c) { return 0; } } class Holder
3
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
4
by: Påhl Melin | last post by:
I have some problems using conversion operators in C++/CLI. In my project I have two ref class:es Signal and SignalMask and I have an conversion function in Signal to convert Signal:s to...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
6
by: Peter Lee | last post by:
what's the correct behaver about the following code ? ( C++ standard ) I got a very strange result.... class MyClass { public: MyClass(const char* p) { printf("ctor p=%s\n", p);
2
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Suppose there are 2 classes A and B with a int parameter called 'val' in each. Both of them provide a public constructor with int type parameter. Suppose class A provides a explicit conversion...
5
by: Ivan Velev | last post by:
Hello, Minimal example below - it gives me different output if I comment / uncomment the extra time.mktime call - note that this call is not related in any way to main logic flow. When...
8
by: Nikola | last post by:
Hello, I'm writing a String class for C++ and I'm getting the following error message when using operator: test.cpp: In function ‘int main()’: test.cpp:7: error: ISO C++ says that these are...
21
by: REH | last post by:
It it permissible to use the constructor style cast with primitives such as "unsigned long"? One of my compilers accepts this syntax, the other does not. The failing one chokes on the fact that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.