mprint Print what you see.

  1. Version
  2. Requirements
  3. Usage
  4. Example
  5. Changelogs
  6. Resources

A different approach to print whatever is in your screen.

This is just a wrapper for the javascript code from http://www.bennadel.com, so the features/limitations from the said script will also be found in this extension.

Version

1.1r1

Requirements

Yii 1.1 or above jQuery

Usage

Extract it under your /extensions directory.

Declare the largest element as the 'element', and just add the unneeded DIVs or classes under exceptions.

Edit the mprint.css or/and add css to satisfy your taste.

Debug mode is added so that you can play with the the page that you will be printing.If you enable this feature, you can set the dimensions of the mPrint section (which appears at the bottom of the page) by overriding dbgWidth and dbgHeight, which defaults are set to 100%. Printing will not proceed if debug mode is enabled.

Example

<?php
     $this->widget('ext.mPrint.mPrint', array(
          'title' => 'title',          //the title of the document. Defaults to the HTML title
          'tooltip' => 'Print',        //tooltip message of the print icon. Defaults to 'print'
          'text' => 'Print Results',   //text which will appear beside the print icon. Defaults to NULL
          'element' => '#page',        //the element to be printed.
          'exceptions' => array(       //the element/s which will be ignored
              '.summary',
              '.search-form'
          ),
          'publishCss' => true,       //publish the CSS for the whole page?
          'visible' => Yii::app()->user->checkAccess('print'),	//should this be visible to the current user?
          'alt' => 'print',	      //text which will appear if image can't be loaded
          'debug' => true,            //enable the debugger to see what you will get
          'id' => 'print-div'         //id of the print link
      ));
?>

Changelogs

1.1r1

  • appended the id in registerScript so as to work on multiple print links on the page (thanks tommo)

1.1

  • used the element declared by the user instead of adding the class mprint (thanks Trejder)
  • added the property id, which will serve as the id attribute of the print link

1.0

  • added the property cssFile which is intended to replace css so as to avoid confusion for those who are used to in cssFile variable (besides, it is more definitive since it is a property for a css file)
  • added property dbgHeight and dbgWidth, which will be the size of the debug portion
  • added the property timeOut which will tell how many seconds before the iframe disappears. This will only be usable if debug is set to false
  • added the method mCssFile which will manage what value to use between css and cssFile property
  • made some adjustments with the js
  • fixed the code so as to make use of $cssFile variable more effectively (thanks tydeas_dr)

0.1.0

  • added the variable 'debug' so that the result can be seen and checked first before sending it out to the printer
  • enhanced the passsing of parameters to the js by using json_encode function
  • enhanced the js code (added $.fn.print.defaults)
  • fixed some bugs found when using FF

0.0.6

  • added the property 'alt' (string), which is the text that will appear if the image is not available
  • modified the way the property is being checked from isset() to strlen().
  • enhanced the way in producing the image tag and used the Yii-way instead of manually creating it.
  • enhanced (somehow) the documentation.

0.0.5

  • added the property 'showIcon' (bool), which tells whether to include the image in the link or not
  • added the property 'image' (string), which tells the widget what icon to use. With this, different icons can be used in different widget calls (for example, one grid icon to print the datagrid results, and one calendar icon to print the calendar div). It will only be rendered if the properties 'visible' and 'showIcon' are set to 'true'. Default value is 'printer.png'

0.0.4

  • added the property 'visible' (bool), which dicates the visibility of the printing link
  • modified some lines of codes to make it more clearer

0.0.3

  • fixed the way the JS file creates the iFrame (where <head> is inside the <body>)
  • added the execCommand in mPrint.js to fix IE7 and IE8 issue on printing banners

0.0.2

  • fixed the bug 'Missing argument 2 for CClientScript::registerCss()' by replacing registerCss with registerCssFile (thanks to joblo)

  • modified the property 'exemptions' to 'exceptions' for a more definitive term (thanks Gustavo)

  • added the property 'publishCss' (bool), which will dictate whether to register the CSS file for the whole page (for the benefit of CTRL+P).

0.0.1

  • initial release

Resources

JQuery print code came from: http://www.bennadel.com

13 0
20 followers
5 728 downloads
Yii Version: 1.1
License: MIT
Category: Others
Developed by: morcen
Created on: Mar 17, 2011
Last updated: 12 years ago

Downloads

show all