473,950 Members | 27,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1430
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****@discuss ions.microsoft. com> wrote in message
news:72******** *************** ***********@mic rosoft.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****@blueyon der.co.uk> wrote in message
news:%2******** *******@TK2MSFT NGP12.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****@blueyon der.co.uk> wrote in message
news:%2******** *******@TK2MSFT NGP12.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****@discuss ions.microsoft. com> wrote in message
news:BF******** *************** ***********@mic rosoft.com...


"Mark Rae" wrote:
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:%2******** *******@TK2MSFT NGP12.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.Conten tType = "applicatio n/pdf"
Response.Binary Write(fileConte nts);

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.Memor yStream

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

Try
document.Open()

'... manipulate the document here

document.Close( )
Response.Output Stream.Write(m. GetBuffer(), 0, m.GetBuffer.Len gth)
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
6713
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 variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
11
12829
by: Aaron Queenan | last post by:
Given the classes: class Class { public static implicit operator int(Class c) { return 0; } } class Holder
3
12030
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 as ODBC, then i am getting
4
2915
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 SignalMask:s. The reason is I have a free function called WaitSignal that accepts av SignalMask where Signals parameters are supposed to implicitly be converted to SignalMask:s. I'm using the SignalMask class because I want to be able to supply a logic...
0
2302
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 pages to a variety of formats. SII's service bureau has a reputation as being a least-cost provider that can offer a timely turnaround with 100% accuracy. Here are some of the formats SII has converted over the last 20 years:
6
2361
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
2540
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 operator taking B object as a parameter and returning an A object. A objA = new A(10); B objB = new B(5); objA = (A)objB; --call public static explicit operator A(B objB) --This method will return "new A(objB.val)"
5
2141
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 "problematicStamp = ..." is commented I get gmtStamp: 1130634600.0
8
5123
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 ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: string.h:19: note: candidate 1: char Types::String::operator(unsigned int) const
21
2486
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 type is not a single identifier or keyword. Which one is correct? For example: unsigned long x = unsigned long(y); REH
0
10171
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9991
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11365
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7442
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6231
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6352
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.