Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jmjimenez

    (@jmjimenez)

    Your last suggestion has done the magic 🙂

    Now, I access to:

    • {post}/pdf
    • {post]/pdf-template

    And this piece of code in my pdf-template works fine:

    <?php wp_footer(); ?>
    <?php
          if ($_SERVER['HTTP_USER_AGENT'] != '') {
             echo '<script type="text/javascript"> window.print(); </script>';
          }
    ?>

    Thanks!!!

    Thread Starter jmjimenez

    (@jmjimenez)

    The static <script> alternative does’t work because in some browser (for example, firefox) the pdf is opened inside the browser AND the static <script> is executed 🙁

    It is something strange, my script is:

    <?php wp_footer(); ?>
       <script type="text/javascript">
          if (location.href.indexOf('pdf-preview') != -1) {
             window.print();
          }
       </script>

    That is: I only want to execute the window.print when the browser is in pdf-preview. However, the window.print() statement is executed by firefox.

    This is the reason I want to render only the <script> when I access the /pdf-preview choice

    Perhaps it may help you:

    I’m having issues generating pdf for some pages in my wordpress. My server shows me this error:

    Fatal error: Allowed memory size of 104857600 bytes exhausted (tried to allocate 1540932 bytes) in /myserver/wp-content/plugins/wp-pdf-templates/dompdf/lib/class.pdf.php on line 1567

    I have reported it to my hosting provider (I think it needs to reconfigure php.ini but it’s a shared host and I can’t do it by myself)

    Thread Starter jmjimenez

    (@jmjimenez)

    Thanks for your quick response

    Your suggestion was my first intention

    To check it, I have include in my test environment a trace in my pdf-template:
    <h5>the request uri is <?php echo $_SERVER['REQUEST_URI']; ?> </h5>

    If I open the post/pdf-preview url, I can read the following:

    the request uri is /listing/chalet-pareado-de-700-m2-en-habana/?pdf-template

    If I open the post/pdf url, the output is the same 🙁

    Any tips?

    Thanks again for your help

    Perhaps your plugin creates a custom post type. In that case you should read this link: http://ww.wp.xz.cn/support/topic/product-post-type?replies=5

    to find out if you have a custom post type, you should read your functions.php file inside your theme (or perhpas insider your plugin source code) looking for something like this:

    register_post_type( 'listings', ...)

    In this example, it’s registered a custom post type ‘listings’

    If so, you must setup wordpress-pdf in your functions.php:

    if(function_exists('set_pdf_print_support')) {
    	 set_pdf_print_support(array('post', 'page', 'listings'));
    }

    Hope it helps…

Viewing 5 replies - 1 through 5 (of 5 total)