473,748 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print Pdf directly (without preview) from client side (using asp.net)

Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearC ontent();
Response.ClearH eaders();
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
Response.Conten tType = "applicatio n/pdf";
Response.Binary Write(memStream .ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javas cript">
window.print();
</script>
I tried also with frameset (don't work)
and I tried also

with

<script language="javas cript">
var oWnd = window.open("Te stPrint.Aspx", "tstPrint") ;
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".
Can you help me????

Thanks in advance!!!

Bye bye
Nov 18 '05 #1
2 14302
you can not directly print a pdf file in a browser, nor can you include
javascript. when the browser detects a pdf file, it looks an activex control
assigned to the mime type, in this case adobe reader. it then loads adobe
reader active/x control, and gives the control the url. the reader control
then requests and downloads the content (if you have ie 6.0 with service
packs, the download will come from the cache, otherwise the pdf is
downloaded again) and renders it.

-- bruce (sqlwork.com)
"AP No spam" <al******@lycos .it> wrote in message
news:fb******** *************** ***@posting.goo gle.com...
Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearC ontent();
Response.ClearH eaders();
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
Response.Conten tType = "applicatio n/pdf";
Response.Binary Write(memStream .ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javas cript">
window.print();
</script>
I tried also with frameset (don't work)
and I tried also

with

<script language="javas cript">
var oWnd = window.open("Te stPrint.Aspx", "tstPrint") ;
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".
Can you help me????

Thanks in advance!!!

Bye bye

Nov 18 '05 #2
Just tested this, and it works, except the pdf does have to load up in the acrobat plugin, but you do get prompted for the print dialog as well.

<iframe> that holds the pdf, and only the pdf
then from the main page, use this javascript to print the iframe.

<script type="text/javascript">
function pdfPrint(iframe )
{
iframe.focus();
iframe.print();
}

pdfPrint(iframe _id);
</script>

You can use Page.RegisterSt artupScript to add this script easily from asp.net.

--Michael
"AP No spam" <al******@lycos .it> wrote in message news:fb******** *************** ***@posting.goo gle.com...
Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearC ontent();
Response.ClearH eaders();
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
Response.Conten tType = "applicatio n/pdf";
Response.Binary Write(memStream .ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javas cript">
window.print();
</script>


I tried also with frameset (don't work)
and I tried also

with

<script language="javas cript">
var oWnd = window.open("Te stPrint.Aspx", "tstPrint") ;
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".


Can you help me????

Thanks in advance!!!

Bye bye

Nov 18 '05 #3

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

Similar topics

16
11435
by: Neo Geshel | last post by:
I'm helping on a web site, and it's got our knickers in a knot. We're using the same basic CSS files (with mods) and same headers as from our other sites, but the "print preview" won't work correctly on this site. The site is here: http://askdrray.kabis.net (temporary location) The site is being worked on, and only the front page works right now. Expect constant changes. Ignore everything “below the fold”, as the links there...
2
2221
by: Martin | last post by:
I have encountered a bug in print preview: In my program, data for printing is taken from arrays. When print preview is invoked or page is printed directly, it is ok, but when user prints from print preview, any data that was in array is not draw, so only thing printed is header and footer. Arrays with data are in the same scope as variables holding header and footer data. They do not loose data and they are not reset as I can access...
2
1950
by: Yuriy | last post by:
Hello! I need to print PDF Document by clicking a button on .aspx page. The PDF should be printed on client printer without displaing it on the window. I tried Process namespace but it doesn't work. Please, help! Thank you.
6
1791
by: Neo Geshel | last post by:
About 4 months ago I came across this one web page that talked about streaming raw image data (from a database, for example) directly to a web page without requiring a secondary ASPX page to output the data as an image. I cannot remember if it talked about having the raw data inline with the HTML page, or having it bound to a server control. Does anyone know the article that I am talking about? TIA
6
3473
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page and not show the templated fields, (hyperlinks) and also not print those fields?
9
4077
by: igotyourdotnet | last post by:
I need to create a print preview page BUT my page I need to print has a grid and in the grid I have 2 or 3 columns that have links I want to hide the columns with the links on my print preview page so they don't print. Is that possible to do and if so can someone point me somewhere or show my a code snippet on how to do this?
0
2977
by: John Smith | last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of Crystal Reports. Sometimes the users will preview a report in a Crystal report viewer, and sometimes they will send the report directly to the printer bypassing the Crystal report viewer altogether. When sending the job directly to the printer I use the PrintToPrinter command CR.PrintToPrinter(1, False, 0, 0)
18
4502
by: =?Utf-8?B?SGVyYg==?= | last post by:
I'm using a ReportViewer in ASP.NET. From the development environment it works fine. When published and I try to open the page with the ReportViewer I get the error: An internal error occurred on the report server. See the error log for more details. Do I have something configured wrong? I do not knw where to find the error log to review it.
3
3283
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net page, it uses js to print in IE. It always has the prompting user window appear. I have tried: <input onclick="document.all.WebBrowser.ExecWB(6,6)" type="button" value="Print directly"> <input onclick="document.all.WebBrowser.ExecWB(6,2)" type="button" value="Print directly">
0
8822
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
9236
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8235
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 projectplanning, coding, testing, and deploymentwithout 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...
1
6792
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4592
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
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
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
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.