By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Print a pdf from asp

P: n/a
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 :

===================================
IRw4??*^E,>?Ob?vX?>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:sps?P?????/@e?Q??",
'-?a;?`?<JZ?@ ??5??? ?r?r??j?>"? dq?vT ?HgCT\Nf;????-ec?=?z
2<XQ}c H?#>?8E})fc!?5??R?^o"H?G?,?^mU6?"??M $?? /6J?U..Ae?
??%?????T?m??fAca?#?B*?sQ???1wO~??E?wJ "?`?}
x??P?|"?,O?V$?#?.<?oXFOl?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?RW??f???D??(?OP7???zBO?[`;,????4?]?]?"M??`"
j"Zd{!>??oO?@'?H|{ln?!?>??1?Wlx .?R{lI"??1, 
'??k=_l?*$?v6\>9EcN??hc <>jI.??9>9?<?!l.'
mz?????L?k?5"?bsb?p??<c JRj]6??wX0>(?9?+$b+??"?
?H??K6?Wu?~?9>bY?Jo,-??? T??@-A???????6? 6?.??`??rx?b?A?
buZ=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???.?9wl'O
??.@.C?8?b]T1??_?y.|?\h?? mT<-?"0qd?L>l?
V??????fpd9t<?h_?O%{Oe??2%-b<O ?v5}???ST?*90??c'?b??"??-:
z6c)?????%,??>?ON?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*AeK'.?s?V???V ?Cp1?qg?h
'??bQ1V?a?4KG!&J"??WFV7?%{?6u' ??" ?j"
???=D@Sc??N??
*ZI>o??fKT$Tdxrz+????6^}?y]!?y???y?c{?f ?.?^tU)!d >
1 ?3<W??e?fWagdeTMq ?*?A}?[ac1?]X?l?6??l0?H?GnNWz??U5?
U?Xl????&V?m ??F???\XClO??M<??
TKLSe?x3?^??,N??P?"?????a?s(6e?? L3?h<;C??"
?b????:6[?AU"
??8?g6CJ-??b"y?opa?^"*?QB????Rf3??M`?t?d-T?_}[J-a??
??"~2C"^l?????7.^*?????? )??T?4lm?B???uU#? >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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
~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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.