473,383 Members | 1,953 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,383 software developers and data experts.

Print a pdf from asp

Hi Everybody

I have a problem opening a file with ADODB.Stream when <HTML> exists on the
same page

here is the code I use :

===================================
<HTML>
<%
Response.ContentType = "application/pdf"
Const adTypeBinary = 1
Dim strFilePath
strFilePath = PathOfTheFile
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
%>
<BODY onLoad="javascript:window.self.print();">
</BODY>
</HTML>
<%objStream.Close
Set objStream = Nothing%>
===================================

I specially use this code to open pdf files and print them after, when I
remove all html tags and leave just the asp code, the pdf fileget opened
correctly, but when I add thez html to code to print it I got page full of :

===================================
I¼îRw4?¾³?*^E,>?Oµàb?vàX?>ê7??#?-?ô?bp[^?·9?>?´£1ô?m?`\ ?LJ÷ô
1??M}ô?¤?o"?,??c3?î/f{T*ùù´??â'³³? .<?±à?u?l(8?î??
?pk~û?é'A?>M¼÷~³i¤>?Ka?OxP!¹?
?"c?f?eCù-»??ç#{/?zô??,r?>²i+¹´<i§?.?8:¸sp¤s?P??¯???/@e?Q??",
'-?½a;?`?<êJZ?@ ??5??? ?r?r?¦?j?>"? dq?vT ?HgC½T¶\Nf;????-ec?=?³z
2<¦X¨Q}c H?#>?8¨E})fc!?ê5??R?^o¦"¸Hü?G?,è?^mU6?"??M $?? /6J?U..Ae?
??%??¬???T?²m??fAca?#?B*?sQ?î»??1wO~??E?¥²éwJé "¹?`?}
x??P?|"?,O¼?V$?#?.<?¦oXF¥Ol?J,??®¬¢²????ë??? '
T?*./H£&?¾±·V!b?.?8??׫l?Z?´??·S??· S,è<«U?^dI>fè? IC~??x[3?¨?&h²
u?çlpck&^M-«l?dhP¶?Y׫?e#ê9?¯B?K+? ?¼~??{???6?O sH???A?~
",?g?R®Wµ?¦?f?è??D??(?OP7??²?zB×O?[`;,???¦?4?]?]?"M??`"
j÷"Zd{!>±??oO?ü@'?H|{l¨n?!?>??1âµ?·Wlx .?R{lI"??1, 
'??çk=_¶l?¶*°$?v²6\>9EcN??h´½cè <>jI.??®9>9?<?!l.'
mïz?????L?k?5"?b³sb?p??<´½cè JRj©]6??wX0>¹(û?9?+¶$b+?¬?"?³
?ü½H??K6?Wu?~?½9>bY?Jo,-??ô? T??@-°A???????6? 6³?.??`¯½??r°x?b¥?A?
b°uZ=c??¨6g?a;,T²??/s?½Ce{?f>'¬??" ?°¥?¦26o'
?~¹½C?>ir?eDf{"´9?4??JS(â2?Y ×??³?De?j'??rS?e?l(ïl?}???
©?2e?A`???K?j¨¤?A?>;?? @S6\?¸r3?¾??.?9»¸°wl'O
??.@³.C?8?b½]¢T1??_?y¥.|?\h??¶ mT<-?"÷0qd²?L>lü¯«ï?
¨V??????fpd9t¦¤<?h×_¼?O·%{Oe±??2%÷-b<O ?v¼5}???µST?*90??âc³â'?b??"??-:¤
¶µz6c)?????%,·?é?·>?O¸N?mx?³à?Z?%îüP'{QTZd3?¨¼? ?µ.k@P5?5*)3??d??b î????
'?vr´§?¾?T>?M¬??IH ?Lb?.??c?&?¶vè?V?j6«??V>?+?NI[?1£,?^I")¤9'
#A9??:6H?9?ü?d*Ae¶Kë'.?s?V???V ¸?Cp1?qg?h
'??÷b¯Q1¾V?´ôaô?4¢KG!&½J"®??WF½V«7?%{?6u' ??" ?j"
?ç³??ë³=D@S¶c??N¯??
*ZI>o??fK¦T$Tdxr¼z+¨?¶¹???²6^}?yü]!?ü©y©???yé?¸c{¤?f £?.?¢^tU)!¶d >
1 ?3<¥W??e?µfWag«deTM³qâ ?*?A}üü?¸±[ac1?]X?l?6??l0?Hï?Gn½NWz??U5û¤?°
U¶?Xlè?ê???&êV?£m ??F???\XClO®?ë?M<??
TKLSe?®x3?^??·,N?¶²?×P?"?????a?s(©6e?ùô? L²3?h<;C??"
?b¶????:6[?AU¾"
??8?êg6CJ-??b«"y±?o³pa?¶^â"*?QBù????R¹£÷f3??M½`»?t?d-³T?³_}[J-ûa??
??"~2C"^l?????7µ.^*ü??????· )??T?4lm?B?¹??u²U#?é >9r?¾"?´??¹|¹?P\¸??"
2[!/¶u9r?3x^ü?U9.1???3<|E?-L"i???¯².-y?o? ûQ"ק?8j-??¯xî?¶. ?'P#F
'?0??¤½?b¥{??$??²)'????|G???[?l?*¶·\¦x?H'?>¸
gIh?|Z??¬?bL¬??m?<F"!¨·.7ü??..~¶$
===================================

and the print dialog box.

what's wrong with my code.

Thanks in advance

Moony
Dec 29 '05 #1
6 3362
You can either return the binary PDF file, or an ordinary HTML file. You
can't mix them together like that. I believe that Acrobat Reader supports
javascript itself and you can put some sort of "print on load" statement in
the PDF (if that's an option for you), but that would be something for the
Acrobat experts to explain, I reckon. Or, just rely on the fact that most
people know how to click a print button and just give the PDF. Even if what
you were trying to do would work, the user would still have to confirm that
he wants the document to print.

Ray at work

"moony marouane" <la********@yahoo.fr> wrote in message
news:u5**************@TK2MSFTNGP11.phx.gbl...
Hi Everybody

I have a problem opening a file with ADODB.Stream when <HTML> exists on
the
same page

here is the code I use :

===================================
<HTML>
<%
Response.ContentType = "application/pdf"
Const adTypeBinary = 1
Dim strFilePath
strFilePath = PathOfTheFile
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
%>
<BODY onLoad="javascript:window.self.print();">
</BODY>
</HTML>
<%objStream.Close
Set objStream = Nothing%>
===================================

I specially use this code to open pdf files and print them after, when I
remove all html tags and leave just the asp code, the pdf fileget opened
correctly, but when I add thez html to code to print it I got page full of
:

Dec 30 '05 #2
Many thanks Ray for your reply..
I got it now, but what if I want to print the pdf file without opening it,
using his path (the path I use to open it, in the code I put in my first
post.), could it be possible??
Thanks again.
Moony
Jan 2 '06 #3
~Perhaps~ it's possible with scripting in the PDF, but I doubt it,
especially considering that you'd have to open the pdf to get the scripts to
run. Even if you can do this, do you really want to just assume that your
visitors wants jobs being sent to their printers without their knowledge?
What happens when someone's default printer is print-to-text-file or
something?

Ray at home

"moony marouane" <la********@yahoo.fr> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Many thanks Ray for your reply..
I got it now, but what if I want to print the pdf file without opening it,
using his path (the path I use to open it, in the code I put in my first
post.), could it be possible??
Thanks again.
Moony

Jan 2 '06 #4
Actually I have in front of each file name (in the asp page that lists those
files) 3 links (download / open / print), the 2 first links work fine
(download / open), now I'm working on the third link (print), that means
that my visitors do know that they're going to print that file when clicking
on the print link.
Now what about the possibility to print without opening.
I guess that's impossible.

Thanks again Ray.

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> a écrit dans
le message de news:u0****************@TK2MSFTNGP14.phx.gbl...
~Perhaps~ it's possible with scripting in the PDF, but I doubt it,
especially considering that you'd have to open the pdf to get the scripts to run. Even if you can do this, do you really want to just assume that your
visitors wants jobs being sent to their printers without their knowledge?
What happens when someone's default printer is print-to-text-file or
something?

Ray at home

"moony marouane" <la********@yahoo.fr> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Many thanks Ray for your reply..
I got it now, but what if I want to print the pdf file without opening it, using his path (the path I use to open it, in the code I put in my first
post.), could it be possible??
Thanks again.
Moony


Jan 3 '06 #5
if you want to do that you need away from web page technology and consider
making a little application that the user runs on their local system. It
would grab the files over the internet and print them out automatically.

its not a topid for this newgroup... its desktop app programming..
"moony marouane" <la********@yahoo.fr> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
Actually I have in front of each file name (in the asp page that lists
those
files) 3 links (download / open / print), the 2 first links work fine
(download / open), now I'm working on the third link (print), that means
that my visitors do know that they're going to print that file when
clicking
on the print link.
Now what about the possibility to print without opening.
I guess that's impossible.

Thanks again Ray.

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> a écrit
dans
le message de news:u0****************@TK2MSFTNGP14.phx.gbl...
~Perhaps~ it's possible with scripting in the PDF, but I doubt it,
especially considering that you'd have to open the pdf to get the scripts

to
run. Even if you can do this, do you really want to just assume that
your
visitors wants jobs being sent to their printers without their knowledge?
What happens when someone's default printer is print-to-text-file or
something?

Ray at home

"moony marouane" <la********@yahoo.fr> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
> Many thanks Ray for your reply..
> I got it now, but what if I want to print the pdf file without opening it, > using his path (the path I use to open it, in the code I put in my
> first
> post.), could it be possible??
> Thanks again.
> Moony
>
>



Jan 3 '06 #6
You mean, an application that visitors should install on their local
machines before printing???
If yes, I think it's impossible coz it's a hosted website not an intranet,
and I can't know all visitors...
correct me if I'm wrong.

Moony

"Kyle Peterson" <ky*****@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP15.phx.gbl...
if you want to do that you need away from web page technology and consider
making a little application that the user runs on their local system. It
would grab the files over the internet and print them out automatically.

its not a topid for this newgroup... its desktop app programming..
"moony marouane" <la********@yahoo.fr> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
Actually I have in front of each file name (in the asp page that lists
those
files) 3 links (download / open / print), the 2 first links work fine
(download / open), now I'm working on the third link (print), that means
that my visitors do know that they're going to print that file when
clicking
on the print link.
Now what about the possibility to print without opening.
I guess that's impossible.

Thanks again Ray.

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> a écrit
dans
le message de news:u0****************@TK2MSFTNGP14.phx.gbl...
~Perhaps~ it's possible with scripting in the PDF, but I doubt it,
especially considering that you'd have to open the pdf to get the scripts
to
run. Even if you can do this, do you really want to just assume that
your
visitors wants jobs being sent to their printers without their
knowledge? What happens when someone's default printer is print-to-text-file or
something?

Ray at home

"moony marouane" <la********@yahoo.fr> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
> Many thanks Ray for your reply..
> I got it now, but what if I want to print the pdf file without

opening it,
> using his path (the path I use to open it, in the code I put in my
> first
> post.), could it be possible??
> Thanks again.
> Moony
>
>



Jan 5 '06 #7

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

Similar topics

12
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__...
14
by: Marcin Ciura | last post by:
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version:...
0
by: bearophileHUGS | last post by:
There is/was a long discussion about the replacement for print in Python 3.0 (I don't know if this discussion is finished): http://mail.python.org/pipermail/python-dev/2005-September/055968.html ...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
1
by: Steff | last post by:
I am wandering if my code is making sense... I use a lot the print function. Is it weird in this case where I have to display an array ? I thought it would be better to have the entire array in php...
3
by: James J. Besemer | last post by:
I would like to champion a proposed enhancement to Python. I describe the basic idea below, in order to gage community interest. Right now, it's only an idea, and I'm sure there's room for...
69
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of...
2
by: Brad Pears | last post by:
I have some sample code that uses the print dialog, print preview and a print direct options. If I select print preview and then click the printer icon from that, the document prints. If I...
7
by: samslists | last post by:
Am I the only one that thinks this would be useful? :) I'd really like to be able to use python 3.0's print statement in 2.x. Is this at least being considered as an option for 2.6? It seems...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.