locked
printThis.js sometime do not print content RRS feed

  • Question

  • User-1634604574 posted

    i am using this plugin  <script src="~/PrintThis/printThis.js"></script>

    to print this div but sometimes will not display all contents inside that div

    $("#p_print").click(function () {

    $('#div_content_print').printThis({

    });
    })

    Sunday, January 12, 2020 4:15 PM

All replies

  • User475983607 posted

    If you need community debugging support than share enough code to reproduce the issue.   

    Otherwise use the browser's dev tools to debug your code.

    Sunday, January 12, 2020 4:25 PM
  • User-1634604574 posted

    i have this plugin i want hide print preview immediately print it how can i do it?

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>jQuery print-preview.js Plugin Demo</title>
        <link rel="stylesheet" href="css/960.css" type="text/css" media="screen">
        <link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="css/print.css" type="text/css" media="print" />
        <link rel="stylesheet" href="../src/css/print-preview.css" type="text/css" media="screen">
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
        <script src="../src/jquery.print-preview.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            $(function() {
    
                /*
                 * Initialise print preview plugin
                 */
                // Add link for print preview and intialise
                $('#aside').prepend('<a class="print-preview">Print this page</a>');
                $('a.print-preview').printPreview();
    
                // Add keybinding (not recommended for production use)
                $(document).bind('keydown', function(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if (code == 80 && !$('#print-modal').length) {
                        $.printPreview.loadPrintPreview();
                        return false;
                    }
                });
            });
        </script>
    </head>
    <body>
    
    <div id="header" class="container_12">jQuery print-preview.js Plugin Demo</div>
    
    <div id="content" class="container_12 clearfix">
    
        <div id="content-main" class="grid_8">
            <h1>jQuery print-preview.js</h1>
            <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- jQuery_download_side -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:300px;height:250px"
         data-ad-client="ca-pub-2783044520727903"
         data-ad-slot="5747103992"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    
            <h2>Labore et dolore magna</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            <div class="gallery">
                <div class="items">
                    <div><img src="https://placeimg.com/140/280/animals" alt="" /></div>
                    <div><img src="https://placeimg.com/140/280/arch" alt="" /></div>
                    <div><img src="https://placeimg.com/140/280/nature" alt="" /></div>
                    <div><img src="https://placeimg.com/140/280/people" alt="" /></div>
                </div>
            </div>
    
            <h2>Pellentesque habitant morbi</h2>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
        </div>
    
        <div id="aside" class="grid_3 push_1">
            <div id="nav">
                <h2>Consectetur adipisicing</h2>
                <ul>
                    <li><a href="#">Lorem</a></li>
                    <li><a href="#">Ipsum dollar</a></li>
                    <li><a href="#">Sit amet consectetur</a></li>
                    <li><a href="#">Sed do eiusmod</a></li>
                    <li><a href="#">Tempor incididunt</a></li>
                </ul>
            </div>
    
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
        </div>
    </div>
    
    <div id="footer" class="container_12">
        <div class="grid_6">
            <p class="footer-links"><a href="#">Aliquam</a> | <a href="#">Iincidunt</a> | <a href="#">Mauris eu risus</a> | <a href="#">Consectetur</a></p>
        </div>
        <div class="grid_6">
            <p>&copy; All images copyright to their respective owners - courtousy of <a href="http://flickholdr.com/" rel="nofollow" target="_blank">http://flickholdr.com/</a></p>
        </div>
    </div>
    <script type="text/javascript">
    
      //var _gaq = _gaq || [];
      //_gaq.push(['_setAccount', 'UA-36251023-1']);
      //_gaq.push(['_setDomainName', 'jqueryscript.net']);
      //_gaq.push(['_trackPageview']);
    
      //(function() {
      //  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      //  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      //  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      //})();
    
    </script>
    </body>
    </html>
    

    Sunday, January 12, 2020 5:05 PM
  • User475983607 posted

    i have this plugin i want hide print preview immediately print it how can i do it?

    It is not possible to print without the user's consent.

    Sunday, January 12, 2020 5:28 PM
  • User-1634604574 posted

    when i clicked on print then print document preview

    Sunday, January 12, 2020 7:31 PM
  • User288213138 posted

    Hi zhyanadil.it,

    According to your description, I couldn’t understand your requirement clearly.

    $.printPreview.loadPrintPreview();

    Can you tell me what this line of code does?

    As far as I know, print specific elements on a page just need to use the following method.

    $('selector').printThis();

    More information about printThis plugin you can refer to this link:https://github.com/jasonday/printThis

    Best regards,

    Sam

    Monday, January 13, 2020 7:42 AM