這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

WordPress PDF Templates

外掛說明

WordPress PDF Templates

This plugin utilises the DOMPDF Library to provide a simple URL endpoint e.g. http://my-site.com/my-post/pdf/ that generates a downloadable PDF file.

If pretty permalinks are disabled. GET parameters (e.g. ?p=1&pdf) can be used instead.

The PDF output can be customized by copying the index-pdf.php file from the plugin directory to your theme and creating your own custom template for PDF prints.

Stylesheets used on the site are disabled by default, but you can define your own stylesheets within the pdf-template.php file. PDF Templates can be previewed as raw HTML at the /pdf-preview URL endpoint.

Source available at https://github.com/anttiviljami/wp-pdf-templates

螢幕擷圖

  • See example use of this plugin here: http://vetrospace.com/

安裝方式

  1. Download and activate the plugin.
  2. Installation done! You can now navigate to any post or page on your website and append /pdf/ (or &pdf if not using pretty permalinks) to the URL to view a glorious PDF version of it.

常見問題集

Installation Instructions
  1. Download and activate the plugin.
  2. Installation done! You can now navigate to any post or page on your website and append /pdf/ (or &pdf if not using pretty permalinks) to the URL to view a glorious PDF version of it.
I activated the plugin but can’t see any difference. What do I do?

WordPress PDF Templates works quietly in the backround without cluttering your wp-admin with unnecessary menus and views.

To see this plugin in action, try navigating to any post or page on your site and appending /pdf/ to the URL.

My PDF is displaying the wrong post content

Is your content access-restricted? In that case, all you need to do is enable cookies for the plugin with define('FETCH_COOKIES_ENABLED', true); in your wp-config.php

You can also try clearing the PDF cache by hard-refreshing your browser or disabling the PDF cache altogether with define( 'DISABLE_PDF_CACHE', true )

How do I enable PDF Templates for custom post types?

You can define supported post types in your theme functions.php with set_pdf_print_support($post_types)

The set_pdf_print_support function takes an array of post types (strings) as a parameter.

Example:
// add pdf print support to post type ‘product’
if(function_exists(‘set_pdf_print_support’)) {
set_pdf_print_support(array(‘post’, ‘page’, ‘product’));
}

I don’t like the way my PDF printing looks. How do I change it?

Just copy index-pdf.php from wp-content/plugins/wp-pdf-templates/ into your theme directory and start editing!

If you wish to define different templates for different post types, you can do that too! Let’s say you wish to create a new PDF template for pages. Just create a file called ‘page-pdf.php’ and create your template there. Note that this only works when a page.php exists in your theme.

Can I change the PDF output paper size, orientation or DPI?

Yes! You can define settings for the DOMPDF Library by editing your wp-config.php.

Example:
// use landscape A4 sized paper @ 180 DPI
define(‘DOMPDF_PAPER_SIZE’, ‘A4’);
define(‘DOMPDF_PAPER_ORIENTATION’, ‘landscape’);
define(‘DOMPDF_DPI’, 180);

See DOMPDF documentation for more options.

My fonts don’t show in the PDF. Can I fix that?

DOMPDF needs the proper font files to generate PDF files. There’s a font adder utility built in to DOMPDF you can use to import any TrueType fonts. See this link for instructions: https://code.google.com/p/dompdf/wiki/Installation

使用者評論

2023 年 10 月 12 日
The plugin is very nice to export custom PDF (with Custom Post) but since the PHP 8 update on my server, i've an error to generate my PDF…
2017 年 2 月 7 日
Fully customizable PDF generation that can include ACF fields, custom fonts, and custom CSS. Allowing custom PDF template php is genius as it allows every detail to be customized by the developer.
2016 年 9 月 3 日
The plugin works most of the time. It has a major conflict with a few popular plugins written/maintained by reputable plugin developers (namely Digital Downloads, and Awesome Support), wherein the use of PHP sessions breaks other plugins which also utilize sessions in a similar way. That's as far as I understand it at least. Refer to this thread to understand more. I submitted multiple support requests via the wordpress plugin support forum, as well as directly on this plugin's GitHub page. It has been over 2 weeks, and I have not heard anything at all from the developer. It has been almost a month with no reply for another related issue. I wish they would back up their plugin with better support. I'd be willing to pay for it if it meant stability and reliability.
閱讀全部 21 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈WordPress PDF Templates〉的開發相關工作。

參與者

將〈WordPress PDF Templates〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

= 1.4.1
* Automatically fall back to http if https doesn’t work

= 1.4.0
* Updated to newest version of DOMPDF, attribute plugin to @anttiviljami instead of Seravo

1.3.9

  • Just marking compatibility and small cleanup

1.3.7

  • Cookies are now passed as a raw header for a simpler system

1.3.6

  • Added more cookie logic and a fix for non-encoded cookies
  • General cleanup of documentation & code

1.3.5

  • Request cookie relaying is now optional and disabled by default
  • If this update causes any issues, try enabling the constant FETCH_COOKIES_ENABLED

1.3.4

  • Custom fonts are now retained in plugin updates

1.3

  • PHP 5.2 compatibility added, upgraded to newest version of dompdf lib

1.2.1

  • Fixes issue with pretty permalinks disabled. Thanks Triskal!

1.2

  • Cookies added to template requests

1.1

  • HTML output is no longer based on output buffering, which makes everything more stable

1.0

  • Initial release to WordPress.org