[Javascript] problem to print embdad pdf which is in object tag in Fire fox

vivek joshi vivekjoshi07 at gmail.com
Wed Jul 14 08:32:50 CDT 2010


Thanks for the solution ,but it is not working fine in IE ,In IE it shows
Window print box rather PDF print box


On Wed, Jul 14, 2010 at 6:52 PM, Terry Riegel
<riegel at clearimageonline.com>wrote:

> Vivek,
>
> I believe the print() method is only available to the global object window,
> and to the object document.
>
> So in your example it looks like you are trying to print a pdf. Assuming
> that is what you are attempting to do then I would suggest creating a simple
> html document with an iframe in it. Something like...
>
> <html>
>  <head>
>  <script>
>   function doit() {
>    parent.printframe.print();
>   }
>  </script>
>  </head>
>  <body>
>  <iframe name="printframe" src="mypdf.pdf" border="4"></iframe>
>  <button onclick="doit()">click</button>
>  </body>
> </html>
>
> I tested the code above and it seems to work fine with Firefox assuming
> Firefox knows how to deal with pdf files. In other words is Firefox doesn't
> have a plugin to display pdf's inline then it will simply download the pdf.
>
> I would avoid the object tag unless you have a good reason to use it. The
> iframe is basically a way to get another browser window in your existing
> document. This would seem to provide the most consistent experience to your
> users.
>
> That should get you started.
>
> Terry
>
>
>
> On Jul 14, 2010, at 6:15 AM, vivek joshi wrote:
>
> > Hi terry i am not much stronger in javascript ,but i have remove the body
> > tag from the code ,the code is not working fine . and  I tried it with
> div
> > tag also I am not able to do it i,if you have some code then can you send
> me
> > please
> >
> > <html>
> > <head>
> > <script>
> > function doit() {
> > var x=document.getElementById("doodad");
> > x.print();
> > }
> > </script>
> > </head>
> > <frameset rows='*' framespacing='0' border='0' frameborder='0'>
> > <frame id="topframe" name="topframe">
> > <object id="doodad" data="
> >
> http://bnbussys4web1.pb.com/images/LabelToPDF.pdf#toolbar=0&navpanes=0&scrol
> > lbar=0"
> > type="application/pdf" width="500" height="500">
> > </object>
> > <button onclick="doit()">click</button>
> > </frame>
> > </frameset>
> > </html>
> > </head>
> >
> >
> > On Wed, Jul 14, 2010 at 3:38 PM, Terry Riegel
> > <riegel at clearimageonline.com>wrote:
> >
> >> Sure, what does your code look like after employing David and Phillip's
> >> suggestions?
> >>
> >> Terry
> >>
> >>
> >>
> >> On Jul 14, 2010, at 5:27 AM, vivek joshi <vivekjoshi07 at gmail.com>
> wrote:
> >>
> >>> can any one please help me ,for this matter  , till now it is not
> solved
> >>>
> >>>
> >>>
> >>>
> >>> On Mon, Jul 12, 2010 at 7:22 PM, David Lovering <dlovering at gazos.com>
> >> wrote:
> >>>
> >>>>> From what I've seen, Firefox is a lot tighter about grammar
> violations
> >>>> (i.e;
> >>>> mixing frameset and body declarations) in the same .html object.
>  Maybe
> >>>> that's why your code is dying outside IE.
> >>>>
> >>>> Break it down into the details, such as importing a PDF into a .div
> and
> >>>> then
> >>>> trying to print it.  There are a number of examples out there that
> >>>> demonstrate this method, and the ones I've used seem to port well
> across
> >>>> platforms.
> >>>>
> >>>> Really, mixing Framesets and body entities is a violation of the DOM
> >>>> structure (unless as noted earlier you wrap the body in a noframeset
> >>>> pairing, which effectively neuters the body block).  By "cleaning up"
> >> the
> >>>> previous author almost certainly meant "make DOM-compliant".  Your
> code
> >>>> (even reduced) doesn't go through my syntax parser without throwing
> >> flags.
> >>>>
> >>>> -- David Lovering
> >>>>
> >>>> -----Original Message-----
> >>>> From: javascript-bounces at lists.evolt.org
> >>>> [mailto:javascript-bounces at lists.evolt.org] On Behalf Of vivek joshi
> >>>> Sent: Monday, July 12, 2010 7:41 AM
> >>>> To: JavaScript List
> >>>> Subject: Re: [Javascript] problem to print embdad pdf which is in
> object
> >>>> tag
> >>>> in Fire fox
> >>>>
> >>>> <html>
> >>>> <head>
> >>>> <script>
> >>>> function doit() {
> >>>> var x=document.getElementById("doodad");
> >>>> x.print();
> >>>> }
> >>>>
> >>>> </script>
> >>>>
> >>>> </head>
> >>>> <body>
> >>>>
> >>>> <frameset rows='*' framespacing='0' border='0' frameborder='0'>
> >>>> <frame id="topframe" name="topframe">
> >>>> <object id="doodad" data="
> >>>>
> >>>>
> >>
> http://bnbussys4web1.pb.com/images/LabelToPDF.pdf#toolbar=0&navpanes=0&scrol
> >>>> lbar=0"
> >>>> type="application/pdf" width="500" height="500">
> >>>> </object>
> >>>> <button onclick="doit()">click</button>
> >>>> </frame>
> >>>> </frameset>
> >>>> </body>
> >>>>
> >>>> On Mon, Jul 12, 2010 at 6:57 PM, Philip Thompson
> >>>> <philthathril at gmail.com>wrote:
> >>>>
> >>>>> On Jul 12, 2010, at 5:58 AM, vivek joshi wrote:
> >>>>>
> >>>>>> Hi All
> >>>>>>
> >>>>>> can any one please help me. i am not able to print embaded pdf in
> >>>>>> FireFox ,the same code is working fine in IE ,the code is given
> below
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> <html>
> >>>>>> <head>
> >>>>>> <script>
> >>>>>> function doit() {
> >>>>>> //alert("x");
> >>>>>> var x=document.getElementById("doodad");
> >>>>>> //alert(x);
> >>>>>> //x.click();
> >>>>>> //x.setActive();
> >>>>>> //x.focus();
> >>>>>>
> //window.parent.frames["a"].document.getElementById("doodad").print();
> >>>>>>   x.print();
> >>>>>> }
> >>>>>> </script>
> >>>>>> </head>
> >>>>>> <body>
> >>>>>> <frameset rows='*' framespacing='0' border='0' frameborder='0'>
> >>>>>> <frame id="topframe" name="topframe">
> >>>>>> <object id="doodad" data="
> >>>>>>
> >>>>>
> >>>>
> >>>>
> >>
> http://bnbussys4web1.pb.com/images/LabelToPDF.pdf#toolbar=0&navpanes=0&scrol
> >>>> lbar=0
> >>>>> "
> >>>>>> type="application/pdf" width="500" height="500">
> >>>>>> </object>
> >>>>>> <button onclick="doit()">click</button>
> >>>>>> </frame>
> >>>>>> </frameset>
> >>>>>> </body>
> >>>>>> </html>
> >>>>>
> >>>>>
> >>>>> First, you should probably filter the extra junk out of your
> example...
> >>>>> people don't want to have to wade through it to find what the issue
> is.
> >>>>> Second, you can't have a "body" tag and a "frameset" tag in the same
> >> file
> >>>>> (unless you include a body tag within a "noframeset" tag). I don't
> >> think
> >>>>> this will necessarily fix the issue you're having, but try cleaning
> it
> >> up
> >>>>> first.
> >>>>>
> >>>>> ~Philip
> >>>>> _______________________________________________
> >>>>> Javascript mailing list
> >>>>> Javascript at lists.evolt.org
> >>>>> http://lists.evolt.org/mailman/listinfo/javascript
> >>>>>
> >>>> _______________________________________________
> >>>> Javascript mailing list
> >>>> Javascript at lists.evolt.org
> >>>> http://lists.evolt.org/mailman/listinfo/javascript
> >>>>
> >>>> _______________________________________________
> >>>> Javascript mailing list
> >>>> Javascript at lists.evolt.org
> >>>> http://lists.evolt.org/mailman/listinfo/javascript
> >>>>
> >>> _______________________________________________
> >>> Javascript mailing list
> >>> Javascript at lists.evolt.org
> >>> http://lists.evolt.org/mailman/listinfo/javascript
> >> _______________________________________________
> >> Javascript mailing list
> >> Javascript at lists.evolt.org
> >> http://lists.evolt.org/mailman/listinfo/javascript
> >>
> > _______________________________________________
> > Javascript mailing list
> > Javascript at lists.evolt.org
> > http://lists.evolt.org/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
>


More information about the Javascript mailing list