[EXTENSION] mprint

I have uploaded an extension and you can find it here.

Feel free to comment and test it.

Here is the latest zip file:

1373

mPrint_r3.zip

hi, thanks for ur extension.

i want ask how to show the background (color or picture) at printing result? i tried to give background at my view.php, but there was blank result.

or Maybe must change the mprint.css file?

thanks for your answer

Thanks harits :)

I think your concern is the same with this comment. As of this writing, I can’t find a way yet to include the background of the page/element to be printed. Actually, I haven’t done enough research about this. Not that I’m not interested in enhancing this, but mainly because my hands are tied with my real life projects.

My apologies for the inconvenience.

Just in case you found a way, kindly let me know and I’ll be more than willing to upgrade our extension. :)

First of all, great extenstion, thanx.

Now some thought on multiple prints in one page, aka reaction to this comment.

if we fix the 284th line like suggested

we have to specify different id’s for each and every call of widget, because it is set to default id=‘mprint’ when you not set one, and you end up with non working scenario.

here is example, how it could work, with two links to parts of page that can be printed




<?php

$this->breadcrumbs=array(

	'Report Package'=>array('/reportPackage'),

	'Print',

);?>


 <?php

       $this->widget('ext.mPrint.mPrint', array(

            'id' => 'mprint1',  // !!!you have to set up this one if you want multiple prints per page

            'title' => 'Some title for page',        //the title of the document. Defaults to the HTML title

            'tooltip' => 'testing the print',    //tooltip message of the print icon. Defaults to 'print'

            'text' => 'Print table 1 - Some name of table', //text which will appear beside the print icon. Defaults to NULL

            'element' => '#printable1',      //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?

        ));

  ?>


<div id="printable1">   <!-- this is where you specify name of section you want to print -->

    <center>

    <h3> Some table name</h3>

    </center>

    <br />

    Registration no: <?php echo '11111111';?>

    <br />

    <br />

    <br />

    <table style="border-collapse: collapse; border:1px solid black;">

        <tr style="border-collapse: collapse; border:1px solid black;">

            <td colspan="2"><b>Responsible person</b></td>

            <td style="border-collapse: collapse; border:1px solid black;">Organization ID</td>

            <td>provide some $model->ico</td>

        </tr>

        <tr style="border-collapse: collapse; border:1px solid black;">

            <td>Name</td>

            <td>$model->name</td>

            <td style="border-collapse: collapse; border:1px solid black;">Person</td>

            <td>$model->filledBy</td>

        </tr>

        <tr>

            <td colspan="2">

                <table>

                    <tr>

                        <td colspan="4">Address</td>

                    </tr>

                    <tr>

                        <td>Street:</td>

                        <td colspan="3"> $model->adresa</td>

                    </tr>

                    <tr>

                        <td>City:</td>

                        <td>$model->city</td>

                        <td>Zip Code:</td>

                        <td>$model->psc</td>

                    </tr>

                    <tr>

                        <td>Telephone:</td>

                        <td>$model->telephone</td>

                        <td>Faxu:</td>

                        <td>$model->fax</td>

                    </tr>

                </table> 

            </td>

            <td colspan="2" style="border-collapse: collapse; border:1px solid black;">

                <table>

                    <tr>

                        <td colspan="4">Address</td>

                    </tr>

                    <tr>

                        <td>Street:</td>

                        <td colspan="3"> $model->adresa</td>

                    </tr>

                    <tr>

                        <td>City:</td>

                        <td>$model->city</td>

                        <td>Zip Code:</td>

                        <td>$model->psc</td>

                    </tr>

                    <tr>

                        <td>Telephone:</td>

                        <td>$model->telephone</td>

                        <td>E-mail:</td>

                        <td>$model->email</td>

                    </tr>

                    <tr>

                        <td>Faxu:</td>

                        <td>$model->fax</td>

                        <td>URL address:</td>

                        <td>$model-web</td>

                    </tr>

                </table> 

            </td>

        </tr>

    </table>

    

    

</div>


 <?php

       $this->widget('ext.mPrint.mPrint', array(

            'id' => 'mprint2',  // !!!you have to set up this one if you want multiple prints per page

            'title' => 'Some page title',        //the title of the document. Defaults to the HTML title

            'tooltip' => 'testing the print',    //tooltip message of the print icon. Defaults to 'print'

            'text' => 'Print table 2 - Evidencia o obaloch', //text which will appear beside the print icon. Defaults to NULL

            'element' => '#printable2',      //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?

        ));

  ?>




<div id="printable2">   <!-- this is where you specify name of section you want to print -->

    <h3>Evidencia o obaloch</h3>

    <table>

       <tr> 

         <td> some table

         </td>

       </tr>

    </table>

    

</div>



I think it would be good idea to apply that fix in source, and provide some info on multiple prints with it

la-ci

Hi la-ci,

Thanks so much for reminding me. Extension is now updated as requested. Apologies for the inconvenience and the delay.

Thanks again. :)

Hey,

nice Plugin many Thanks!

Short Question:

Is it Possible to Start the Plugin over an Link in CMENU? I have all action right in a small widget and want to add the print Action there also. THis didn’t work =( :

array(‘label’=>‘Print’, ‘url’=>’#’, ‘linkOptions’=>array(‘onclick’=>‘void(0)’))

Any Ideas? Thanks!

Thanks lugaru :)

Basically, what you need to do is to trigger the "click" event of your mprint link. I tried doing something like


'linkOptions'=>array('onclick'=>'javascript: $("#div-to-be-printed").click()')

but the quotations are being encoded so it appears in the page lik


<li><a onclick="javascript: $(&quot;#div-to-be-printed&quot;).trigger(&quot;click&quot;);" href="#">Print</a></li>

and does not work.

So what I did was I created a triggering function:




<script type="text/javascript">

function trigger_click(){

	$("#div-to-be-printed").trigger("click");

}

</script>



and then in my menu I put:


 array('label' => 'Print', 'url' => '#', 'linkOptions'=>array('onclick'=>'javascript: trigger_click()'))

and it worked.

I’m not a jquery expert, but I hope I have given you an idea.

Edit:

Just to be clear, the ‘div-to-be-printed’ is the ‘id’ of the mprint’s print link.

Many Thanks macinville :)

works fine =)

Your welcome lugaru :)

How to make that work with CGridView?

Not working for chrome

:(

Please sugguest how to force it to use system print dialouge

Thanx

Problem with CSS and element to be printed

Hi,

I am having a problem:

When I specify the element to be printed (‘element’=>’.pview1’,), the output ignores the CSS file settings. If I do not specify the element to be printed, the CSS settings are observed but of course, the whole page is printed.

I do not specify cssFile in the parameters so the default is being used (mprint.css) I added my own settings to this file.

Can anyone help me? Thanks

Problem with integration …

1.I’ve mPrint_3.zip unpacked under /protected/extensions/mPrint

2.chmod 777

Alias "ext.mPrint.mPrint" is invalid. Make sure it points to an existing PHP file and the file is readable.

where i go wrong ???

Can anyone help? Thanks

How to make that .

Hello i am newbie on Yii, i try to using ext mprint but not work, can somebody tell me about tutorial instalation?<br />

and how setup on controller ?

Thanks

Hi, I tried to use the extension in a view where the are more than 1 widget, but I have the problem that the first link to print does not have ‘href = “javascript: void (0)”’ … can you help me?

I have used this extension successfully to print a table when using FF (Ubuntu 14.04 FF 33.0) but as soon as I test it on Chrome (Version 38.0.2125.111 (64-bit)) it generates blank pages. I have also seen the same problem with the current version of Opera.

I tried with my modified css file and with the default mprint.css with the same results.

I attach mPrint as:




<?php

    $this->widget('ext.mPrint.mPrint', array(

        'title'=>'Account ' . $account->id . ' - ' . $list->tagname,

        'element' => '#printing-list',

        'id' => 'print-div',

        'showIcon'=>true,

        'cssFile'=>'mlprint.css',

        'text'=>'Print List',

        'htmlOptions'=>array('class'=>'btn btn-warning',)

    ));

?>



then I create the printable table as:




<div id="printing-list" style="display: none;">

    <?php

    echo "<table><thead><tr>";

    foreach($header as $column) {

        list($table,$name) = explode('.',$column);

        echo "<th>" . CHtml::encode($model->getAttributeLabel($name)) . "</th>";

    }

    echo "</tr></thead><tbody>";

    foreach($rows as $row) {

        echo "<tr>";

        foreach($header as $column) {

            list($table,$name) = explode('.',$column);

            $data = $row->$table->$name;

            echo "<td>" . CHtml::encode($data) . "</td>";

        }

        echo "</tr>";

    }

    echo "</tbody></table>";

    ?>

</div>



Any thoughts?

It’s not working on chrome for first click. although second click seems to working fine.

Any thoughts?

Hi all,

I use

$this->widget(‘ext.mPrint.mPrint’, array(

      'title' =&gt; 'title',          //the title of the document. Defaults to the HTML title


      'tooltip' =&gt; 'Print',        //tooltip message of the print icon. Defaults to 'print'


      'text' =&gt; 'Print Results',   //text which will appear beside the print icon. Defaults to NULL


      'element' =&gt; '#print',        //the element to be printed.


      'exceptions' =&gt; array(       //the element/s which will be ignored


          '.summary',


          '.search-form'


      ),


      //'publishCss' =&gt; true,       //publish the CSS for the whole page?


      'visible' =&gt; true,  //should this be visible to the current user?


      'alt' =&gt; 'print',       //text which will appear if image can't be loaded


      'debug' =&gt; false,            //enable the debugger to see what you will get


      'id' =&gt; 'printtoprint'         //id of the print link


  ));

it works for me in Chrome on local machine and doesn’t when I try to print from a hosting

any suggestion, please

Ill rewrite this extension at this week - it not work properly.

Also I want use dnsmasq instead isc-dhcp - it know work as name server for zone local.