Bug 192585 - iFrame printing works in desktop Safari, but not mobile...
Summary: iFrame printing works in desktop Safari, but not mobile...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: Safari 12
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-12-11 03:08 PST by Lou Mazz
Modified: 2018-12-12 15:45 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lou Mazz 2018-12-11 03:08:50 PST
Printing.  Works for me on desktop Safari.  Same code won’t work on iOS Safari.

Not a lot of code:

===================================

	    //"Print" order button on orderItemList page
            $('#orderItemList .toolbar .printButton').live('click', function(event) {
				//test for pending (Submit) or actual
				if ($('#orderItemList .tabbar li').last().text() == "Submit") url = "printableOrderHTML.php?u="+dopeArray[0]+"&c="+dopeArray[1]+"&o="+dopeArray[2];	
				else url = "../ReceiveIt/printableOrderHTML.php?u="+username+"&c="+dopeArray[1]+"&o="+orderNo;
				bPrint(url);			
			});
            
                             
            //Print function caller
            //        SAFARI VERSION DEPENDENT - assumes "sVersion" has correct Safari version
			var iframe;
            function bPrint(url) {
                if (sVersion > "5.0.6")
                    if ($('iframe').html() != null) $('iframe').remove();       // newer Safaris require this done here
            
                iframe = document.createElement("iframe");						// create an iframe so that no window pops up
                document.body.appendChild(iframe);                              // insert the element to the DOM 

                aSp = 0;
                $.ajax({
                    url: url, 
                    success: printCallback
                });            
            } 

			function printCallback(data) {
				var error=/Error:/g;
				if (error.test(data) == true) {
					$('#error #results').html(data);
					jQT.goTo('#error','slideleft');
				}
				else {
					iframe.contentWindow.document.write(data);						// write the HTML to be printed
					iframe.contentWindow.print();                                   // print it
					if (sVersion <= "5.0.6") 
						$('iframe').remove();                                       // older Safaris get this done here, where it should be
					return true;    
				}
			}

==============================


…as I said, desktop Safari likes this just fine.
In iOS, I get a blank preview page.
Apparently I’m not the only one:

https://github.com/mozilla/pdf.js/issues/7597

All iOS12 simulator devices give me a blank page.
Comment 1 Radar WebKit Bug Importer 2018-12-12 13:19:34 PST
<rdar://problem/46673189>
Comment 2 Lou Mazz 2018-12-12 15:42:35 PST
Stupid programmer error - variable "sVersion" test was wrong.
Fixed test - printing works.
Comment 3 Lou Mazz 2018-12-12 15:43:46 PST
Stupid programmer error - xVersion test was wrong, so iFrame was being
deleted.  Fixed test - printing works.
Comment 4 Simon Fraser (smfr) 2018-12-12 15:45:34 PST
Great!