Simple PDF Exporter

Simple PDF Exporter

توسط

Export a single PDF with all posts, or custom post types.
You can also export a single post, or the exact number you need.

IMPORTANT This plugin requires at least 512MB of free RAM available, or it will timeout / return an error.

This plugin is NOT recommended for people with no tech knowledge.
The PDF layout/design is VERY basic and will require html/css/php technical knowledge to customize.
Read more about this below.

The Basics

The plugin checks if a pdf already exists with the same date (ddMonyear), if yes, the existing pdf will be served, otherwise a new will be generated. Since the PDF generation uses up a lot of resources, this will prevent too many runs of the plugin and the crashing of your server.
Check the example below or the FAQ for ways to force the PDF generation anyway.

Depending on how many posts you have, it might take from a few seconds to several minutes for a new PDF to be generated.

If no PDF is generated you probably don’t have enough server resources. This can’t be fixed, as PDF libraries are very resource-hungry.
Ask your hosting to check how many resources you would need to run the plugin and if there is anything you can do, within your hosting limits, to make sure the plugin has enough or appropriate RAM/PHP settings.

If you don’t use a custom url, hence you don’t add the post_type parameter to the url, the default post type exported will always be WP default post.

The PDF Template

Currently, the template and design for the exported pdf, is very basic (and posts are rendered as a table, since floating doesn’t play nicely with the DOMPDF library).

You can copy the plugin’s basic structure from wp-content/plugins/simple-pdf-exporter/assets/pdf_layout.php inside your current theme and edit it.
Your layout must be echoed in php, eg. echo '<div>the content goes here</div>'; or it won’t show up in the PDF.

You can copy the plugin’s basic CSS from wp-content/plugins/simple-pdf-exporter/assets/pdf_export.css inside your current theme and edit it.

Do not edit directly the plugin’s files pdf_layout.php and pdf_export.css, they will be overwritten with the next update.

Questions?

Check the FAQ before opening new threads in the forum!

Contact me if you want a custom version of the plugin, for a fee (email on shambix.com).

Libraries & Credits

  1. Download and activate the plugin.
  2. In order to export a pdf, you can do it from backend from Tools -> PDF Export or enter http://yoursite.com/?export=pdf in your browser. You can also make the url into a link or button on your site, to use on frontend, please check the FAQ.

سوالات متداول

I activated the plugin but can’t see any difference. What do I do?

In order to export a pdf, you can do it from backend from Tools -> PDF Export or enter http://yoursite.com/?export=pdf in your browser.
You can also make the url into a link or button on your site, to use on frontend.

How do I make a button or link for the frontend?

You can add a frontend link or button on your frontend and customize it, like in this example for Twitter Bootstrap:
Change the parameters to suit your needs.

<?php // Check if PDF Export Plugin exists first
if( function_exists('simple_pdf_export_process')) { ?>
    <ul class="nav nav-tabs pull-right pdf_export_menu">
        <li role="presentation" class="dropdown">
        <a class="dropdown-toggle btn" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Export Posts to PDF <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <?php
                    $post_type_to_export = 'portfolio';
                    $final_pdf = SIMPLE_PDF_EXPORTER_EXPORT.$post_type_to_export.SIMPLE_PDF_EXPORTER_EXTRA_FILE_NAME.date('dMY').'.pdf';
                    if(file_exists($final_pdf)) {
                        $file_date = date("d M Y - H:i", filemtime($final_pdf));
                        ?>
                        <li><a class="" href="?export=pdf&post_type=portfolio&num=3" target="_blank">Download Existing Version <small>(<?php echo $file_date; ?> GMT)</small></a></li>
                <?php } ?>
                <li><a class="" href="?export=pdf&post_type=portfolio&num=3&force" target="_blank">Generate New Version <small>(might take several minutes)</small></a></li>
            </ul>
        </li>
    </ul>
<?php } ?>

I want to limit the amount of posts

Use &num=x in your url.
eg. http://yoursite.com/?export=pdf&num=3

I want to export a specific post

Use &post_id=x with the ID of the post or custom post type you need, in your url.
eg. http://yoursite.com/?export=pdf&post_id=3
In this case, don’t use the post_type parameter. The num parameter will be ignored for obvious reasons.

I want to create a PDF from a custom post type

Use &post_type=x.
eg. http://yoursite.com/?export=pdf&post_type=your-post-type-slug

How do I customize the layout of the posts in the pdf?

You need to change the file pdf_layout.php inside the plugin folder wp-content/plugins/simple-pdf-exporter/process/pdf_layout.php
Your layout must be echoed in php. eg. echo '<div>the content goes here</div>'; or it won’t show up in the PDF.

I want to override the existing file / generate a new pdf no matter what

Use &force after your url
eg. http://yoursite.com/?export=pdf&force
This will also invalidate the internal cache, hence it will take more time to generate the PDF. Avoid if possible.

Can I use a custom CSS file?

You can use a custom CSS to customize the layout.
Create a file named pdf_export.css in your theme folder, otherwise the plugin’s default (and really basic) CSS will be used (you can find it here wp-content/plugins/simple-pdf-exporter/assets/pdf_export.css)

Is there some other option I can change?

Yes there’s a few. In order to change them, add them to your wp-config.php file.
eg. define(SIMPLE_PDF_EXPORTER_PAGINATION’, true);

Here’s the full list and what they are set to, by default:

  • define(‘SIMPLE_PDF_EXPORTER_DEBUG’, false); // if true, the output will be in html for debugging purposes
  • define(‘SIMPLE_PDF_EXPORTER_PAGINATION’, false);
  • define(‘SIMPLE_PDF_EXPORTER_HTML_OUTPUT’, false);
  • define(SIMPLE_PDF_EXPORTER_CSS_FILE’, get_stylesheet_directory().’/pdf_export.css’);
  • define(‘SIMPLE_PDF_EXPORTER_LAYOUT_FILE’, get_stylesheet_directory().’/pdf_layout.php’);
  • define(‘SIMPLE_PDF_EXPORTER_EXTRA_FILE_NAME’, ‘-‘);
  • define(‘DOMPDF_PAPER_SIZE’, ‘A4’);
  • define(‘DOMPDF_PAPER_ORIENTATION’, ‘portrait’);
  • define(‘DOMPDF_DPI’, 72);
  • define(‘DOMPDF_ENABLE_REMOTE’, true);
  • define(‘DOMPDF_ENABLE_HTML5’, true); // true by default, since v.1.9.2
  • define(‘DOMPDF_ENABLE_FONTSUBSETTING’, true);
  • define(‘DOMPDF_MEDIATYPE’, ‘print’);
  • define(‘DOMPDF_FONTHEIGHTRATIO’, 1);
How do I debug the layout in HTML form instead of PDF?

You can set define(‘SIMPLE_PDF_EXPORTER_HTML_OUTPUT’, true); in your wp-config.php file, just remember to comment the line or set to false, when you are done debugging.

تصویری برای این آیتم موجود نیست.
نظری برای این آیتم موجود نیست.
0 0 رای ها
امتیازدهی
اشتراک در
اطلاع از
0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
هیچ نسخه‌ای برای این آیتم موجود نیست.
★★★★★
★★★★★
3.5 /5 (4 نظر)

قیمت:

رایگان

نگارش

آخرین انتشار

17 اردیبهشت 1405

آخرین بروزرسانی

3 ماه پیش

نصب های فعال

400+

نگارش وردپرس

-

تست شده از نسخه

وردپرس 6.1.10

نگارش PHP

-

نسخه ها

0 نسخه