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

Terry Riegel riegel at clearimageonline.com
Wed Jul 14 09:01:50 CDT 2010


Vivek,

On my copy of IE it downloads the PDF as I do not have any plug ins installed to handle pdf files.

Perhaps this challenge is a bit much for your level of expertise. I would suggest that you do some reading on how browsers handle non-HTML content. What you are asking for is to have all the browsers handle non-html content the same way. I am not sure this is possible. I can appreciate that you would like to normalize the user experience as much as you can across browsers.

Generally if a web browser can't display a particular type of content then it relies on some sort of plug-in architecture to do the display of that content, it would also rely on said plug-in architecture to print that content.

So I think you need to clarify your expectations, but I think you need to understand how the browsers you are working with (including IE) handle content that it is/was not designed to handle. In you particular case you are asking the web browser to handle PDF content which is not something web browsers do. It would seem you are assuming that all users visiting your site have a particular plug in from a particular vendor for a particular purpose. If that is the case then that needs to be stated in your specification.

Then when you ask on a forum like this there is a known baseline. Once this is known and articulated then we can provide help that is more to the point of what you need instead of what might sound like general suggestions.

If on the other hand you are asking someone on the list to write the code for you then perhaps someone might offer to do that but I kind of doubt that is going to happen.

I hope you find this list helpful and a great resource as I have. I know it is frustrating when you have a particular problem that you just want a solution for and the only responses you get seem to be vague and unhelpful. As someone that has been there done that I can tell you that the responses you have received will help you get to the solution you are after but it will require some googling and reading on your part to get there.



Terry




On Jul 14, 2010, at 9:46 AM, vivek joshi wrote:

> you just try to the same code ,run it on IE ,this show the normal print
> box,but same if you try in Firefox the pdf print box show
> 
> On Wed, Jul 14, 2010 at 7:12 PM, Terry Riegel
> <riegel at clearimageonline.com>wrote:
> 
>> I am sorry I don't know what a window print box is. I also do not know what
>> a PDF print box is.
>> 
>> Terry
>> 
>> 
>> 
>> On Jul 14, 2010, at 9:32 AM, vivek joshi wrote:
>> 
>>> 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
>>>> 
>>> _______________________________________________
>>> 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