www.netsi.dk

"The internet is just a layer on the real world" (don't forget that!)

Printing HTML pages, make screen and print appear the same.

When using external stylesheets on a webpage you can specify which “media” it should apply to. For instance see these lines:

<link rel="" href="Blueprint/screen." type="text/css" media="screen, projection" />
<link rel="stylesheet" href="Blueprint/.css" type="text/css" media="print" />

As you might allready have guessed the screen.css will be choosen for screen (read: browser) and projection mode. When printing the print.css will be choosen if you print the webpage. So far so good.

Some times you will have a specific page for print, which say will render only a stripped down version of your content and prompt the user with a print dialogue (using a javascript window.print() line of code). But when you see the page in the browser you are in “screen” media, and the style shown will be as defined in the screen.css. You may confuse the user as he gets a screen version ready for print – and printing it wil result in a version based on the print.css. I have made a jQuery based fix for this situation.

The page before and after the fix

The jQuery fix

The fix will disable any external stylesheets related to screen and make the print.css work on media types “all”. It is coded so that it will check for a “#print” added to the URL. So you should simply make the URL of the printversion have a “#print” in it. Here is the fix:

   1:  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
   2:  <script type="text/javascript">
   3:  /* STH: 2011-07-07 Make any stylesheets target for "print" media active on "all" media types (including screen)
   4:      Also disable any layouts for screen
   5:  */
   6:  jQuery(function() {
   7:    var bPrint = (window.location.toString().indexOf('#print')!=-1);  
   8:    if (bPrint) {
   9:      // The user wants to print this page
  10:      jQuery('link[media*="print"]').attr('media', 'all'); // Enable the print styling for all media types, including screen.
  11:      jQuery('link[media*="screen"]').remove(); // remove any styling related to screen
  12:    }
  13:  })
  14:  </script>

 

The fix above has a link to jQuery, you do not have to include it if you allready have jQuery on your webpage.

Share

Want to print from your iPad to your windows printer? Here is a quick guide.

I have just bought my first Apple product – an 2, rather nice device I must say Smiley A friend of mine is all Apple, so it’s Apple here, Apple there and Apple everywhere! It is impressive to see how well integrated it all is – but how about integration to my PC? Here I will give you a guide to how you can on a PC connected printer using from your iPad (or I guess) using wireless network and .

What you need…

Well basically you can just follow the guide here on this page: “How to Enable AirPrint Service on Windows 7/Vista/XP (32-bit/64-bit)?”. It involves these steps:

  1. Windows 7 (or perhaps Vista, excuse me for only having Win7 installed)
  2. Share the printer which you want to print to from your iPad/iPhone.
    A Danish version of the control panel
    Open the control panel and locate your printer under “units and printers”
    Choose properties for the printer and click the “sharing”
    Check “Share this printer”
  3. Install iTunes
  4. Download AirPrint installer
  5. Run it as administrator (Right click the downloaded package and choose “Run as administrator”)
    Just follow the instructions of the installer
  6. We need to allow AirPrint features in the windows firewall.
    Locate and click the “Allow a program through Windows Firewall” in control panel security section.
    Click the “Change settings” button if you cannot change the settings by now.
    image

You are now ready to print from your iPad/iPhone to your pc connected printer.

From your iPad you may open your photo album and tab in the top right side:

image

Here you can choose print and the select printer. If your printer does not appear you may need to return to the control panel and remove/add the sharing option.

If you do not see the printer you may even have to add some windows features. Open the control panel and select “Turn on/off windows features” in the left side of the add/remove program section. Then locate the LPD and LPR printer options under the “printing and document services”

image

When you have finished these steps you can print over network from your iPad/iPhone – even if you do not own a Apple computer Smiley

Share