Tag Archives: PDF Creation Station

Finally updated Kalin’s PDF Creation Station WordPress plugin after three years

I’ve been saying I wanted to do this for a long time now, particularly as WordPress had classified my plugin as abandoned after three years of no updates and the TCPDF engine I use has been steadily updated. So today I released a new version of Kalin’s PDF Creation Station, version 3.2. I added a couple little new features, like now you can specify which type of name you want with your post_author shortcodes instead of being stuck with the login name. I also added a couple options to the post_thumb shortcode so you can select a size or set it to try to scrape the post and pull out the first image it finds. I wanted it to be a bit more advanced than that, like being able to specify exact sizes instead of just “small”, “medium” etc, but WordPress doesn’t seem to want to let me do that even though it says it can in the documentation. I also wanted to be able to have an option to randomly select an image scraped from the post instead of just the first image, but that would have taken a lot more work and I figured it wasn’t worth the effort.

Most importantly, though, is the upgrade to the TCPDF engine. I’ve been told this new version is much faster, so hopefully it will be more reliable as well and allow you to create much larger documents, as the old version seemed to conk out if you tried to compile more than 100 or so posts into a single PDF. I was hoping it would have better handling of images and fewer of those weird empty spaces in the final PDF. I think it may do better with the empty spaces, but the image support is still spotty. I’m not sure if that’s the fault of TCPDF or WordPress. It seems like both systems have been steadily updated so I’m not sure why this is still a problem.

I was also working on a plugin called Advanced Post List, which is a fork of Kalin’s Post List, but we both seemed to have burnt out on that one for some reason, even though I made the same two shortcode changes to that plugin that I did to Creation Station so I may wind up updating Kalin’s Post List as well. These plugins did always bring in a lot of traffic to my site, even if the visitors aren’t here to read my stories or opinions, it’s nice to have someone coming here for something.

Thank You and Sorry to My Plugin Users

So in the last six months or so I’ve gotten much worse about answering the frequent comments left on this site regarding my three WordPress plugins, PDF Creation Station, Easy Edit Links and Post List. I want to thank everyone who has left praise for my creations and say that I’m thrilled at the lack of complaints considering what a learning curve they have and the fact that they’ve actually got a fair number of little bugs that I’ve never taken care of because they don’t affect me  when I use them on my own website. I can’t believe Post List and Edit Links are both at a five star rating as of this post.

And I just remembered as I was writing this, that Advanced Post List exists. This is a plugin that someone developed that is based off my Post List code. I remember he contacted me a year or two ago and asked my permission to do this, which of course he didn’t need, but was just being polite. I tried out his version and it didn’t work and I told him that if he got it working and he hadn’t removed any notable features, I’d officially deprecate my Post List plugin and send all my users to his. Then I never heard from him again and figured he’d abandoned the project. Turns out he just did a release earlier this month and has far exceeded my user base and still has nearly a five star rating.

So I need to get my local development version of WordPress up and running so I can install his plugin and make sure it works properly, then replace my plugin with a pointer to his, then I will be done with Post List support forever but the functionality will live on. The best of both worlds. One of the beauties of the open-source arena.

And I know I said I’d get back to working on Creation Station as someone pointed out a bug with disappearing images that I was able to reproduce on my own site, and the PDF engine, TCPDF, has probably come out with updates that need to be added. But frankly, I just have other priorities. I wish someone else would take my Creation Station code and start calling it their own. As far as I know it’s still the best PDF plugin for WordPress and it’s sad that it’s not being developed or actively supported anymore.

And I abandoned Easy Edit Links a long time ago because the WordPress core came out with a solution that solves the same problem… even though Easy Edit Links works better.

So anyway, I’m going back to work on my latest novel, so I’m sorry everyone who has asked a support question and is waiting for a reply. I will probably get back to you at some point, but I may start going through them in batches once a month or so, so I apologize for that.

But I must say, it has been pretty great doing these plugins. Definitely one of the proudest moments of my career, even though I don’t think I made more than two hundred bucks in donations total between all three of them. Most of the code I have written professionally was, in one form or another, designed to get money from people, so it feels good to have supported a community like WordPress.

Customize or Remove Header and Footer in PDF Creation Station

Occasionally folks have asked me if they can remove or customize the headers and footers in my WordPress plugin, PDF Creation Station. Unfortunately I’m trying to focus more on my fiction writing right now so I’m on a development hiatus and haven’t been adding to this plugin. However, if you can hack some simple PHP, someone left this comment explaining how to do it yourself.

Thanks for the info Luis!

yes you can!, i´ve done it on mine, $objTcpdf->SetPrintHeader(false); $objTcpdf->SetPrintFooter(false);

this lines are to remove the header or footer and have to be written on kalins_pdf_create.php somewhere around lines 218 – 220

or search in the tcpdf.php file for –> public function Footer() { function and there you can add some text or change the black line

for example to add some text on the left side of the footer i add

$textofoot = utf8_decode(‘CONFIDENCIAL: La información aqui contenida,es para la evaluación del cliente.’);


Customize/Translate the word ‘page’ in Kalin’s PDF Creation Station

I had someone make a request of my PDF Creation Station WordPress plugin to be able to customize the word ‘page’ which appears before the number at the bottom of each page. I may add a field onto the settings pages for this, but in the meantime, you can customize/translate this word by adding the following code into your wp-config.php file:

define("KALINS_PDF_PAGE_TRANSLATION", "page translation");

Doing this should keep the translation even after I upgrade the plugin.


Change the Order of the Post List in Kalin’s PDF Creation Station

A couple people have asked for the ability to change how the posts are ordered on the Tool page of my PDF Creation Station WordPress plugin so they don’t have to spend so long reordering them before creating. I ultimately would like to create an Ajax script to refresh the list from an ‘order by’ dropdown box. That’s a little complex and time-consuming so I think there are more important things for me to be doing, so in the meantime, for version 3.0, I’ve added a way for anyone with a little PHP experience to change how the posts are ordered. If you look into kalins_pdf_tool_page.php, currently on line 16 you will see this code:

	$customList = get_posts('numberposts=-1&post_type=any&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
	$postList = get_posts('numberposts=-1&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
	$customList = get_posts('numberposts=-1&post_type=any');
	$postList = get_posts('numberposts=-1');

You can see that the code is referring to two constants called KALINS_PDF_POST_ORDER_BY and KALINS_PDF_POST_ORDER. All you need to do is define both these constants in your wp-config.php file. Doing this will keep the setting constant even after upgrading to new versions of the plugin.

define("KALINS_PDF_POST_ORDER_BY", "order type");

You may replace “ASC” with “DESC” to reverse the order. Replace order type with any of these possible values:

  • 'author' – Sort by the numeric author IDs.
  • 'category' – Sort by the numeric category IDs.
  • 'content' – Sort by content.
  • 'date' – Sort by creation date.
  • 'ID' – Sort by numeric post ID.
  • 'menu_order' – Sort by the menu order. Only useful with pages and attachments.
  • 'mime_type' – Sort by MIME type. Only useful with attachments.
  • 'modified' – Sort by last modified date.
  • 'name' – Sort by stub.
  • 'parent' – Sort by parent ID.
  • 'password' – Sort by password.
  • 'rand' – Randomly sort results.
  • 'status' – Sort by status.
  • 'title' – Sort by title.
  • 'type' – Sort by type.

Customize Display of Comments in Kalin’s Post List and PDF Creation Station

In version 3.0 of  PDF Creation Station WordPress plugin, and version 3.0 of  Post List, I added a shortcode for post comments that looks like : [post_comments before=”” after=””]. Naturally the biggest issue with this is that some folks want a specific formatting and perhaps other special handling such as removing pingbacks, customizing name/date formatting or dealing with nested comments. Here’s how you can add your own function to handle post comments in the PDF.

Currently in kalins-pdf-creation-station.php, or kalins-post-list.php, you will see a function called commentCallback($matches). This is currently what processes the comments shortcode. You will see the first thing it does is check to see if you have defined your own comment callback function:

if(defined("KALINS_PDF_COMMENT_CALLBACK")){//remove this if statement if you copy this function to use it as a custom comments function
return call_user_func(KALINS_PDF_COMMENT_CALLBACK);

So the first thing you want to do to create your custom comment function is copy this whole function into your wp-config.php file and give it a unique name. You could probably put it somewhere else and this would still work. Then remove the if statement that checks for your custom callback (very important to prevent infinite loop). Then you simply modify it to display the comments however you want.

The final step is to also put this code into your wp-config.php file and replace the name of the function:

define('KALINS_PDF_COMMENT_CALLBACK', 'my_function_name');

Doing this should give you your custom comments display and should remain in effect even after upgrading to a new version of this plugin.

KalinBooks Entire Blog as PDF (Creation Station Example)

I just released Kalin’s PDF Creation Station version 3.0, which now has better performance on the tool page when creating PDFs, so it should no longer hang/fail/timeout when trying to build a huge file. To prove this, here’s my entire blog as a PDF, including images, and a new feature, a Table of Contents page. To save paper, I used the new feature which allows you to eliminate page breaks between posts. If not, it would have been around 285 pages instead of 174.

What I’m Up To

A couple nights ago I started writing a science-fiction short story that I’ve been running around in my head for almost a year now. It’s passed 2000 words so far, and seems to be going pretty well. I seem to have found “the zone” where the writing goes smoothly and I can really feel the characters. This one is going to have a lot of drama, lots of screaming and crying, some action and suspense, but no violence and no cursing. I like to switch it up sometimes.

Yet another female protagonist. I honestly don’t know why the majority of my fiction is from the female perspective. The stories just always seem to work better.


The other thing I’m currently working on is version 3.0 of Kalin’s PDF Creation Station, my most popular WordPress plugin. I’m hoping with this release to clear up the majority of the feature requests that people have made. My intent is to be regarded as the best of the WordPress PDF plugins.

I’ve already added a bunch of features, which are now available if you have SVN access and download the beta version from the branches folder of this repository: http://plugins.svn.wordpress.org/kalins-pdf-creation-station/

Here’s the list of features already completed and currently in testing:

  • upgraded TCPDF engine. This should improve image handling and also fixes the blockquotes issue, so blockquotes no longer need to use a monospaced font
  • added option to automatically construct a Table of Contents page in the creator tool
  • added post_meta shortcode for post’s custom fields
  • added option on Tool page to turn off automatic page breaks between posts
  • added ability for hackers to translate/change the word ‘page’ to whatever they want
  • added option to run other plugin content filters
  • added post category(s) shortcode
  • added post tags shortcode
  • added option to convert Vimeo videos (works for both object and iframe style embeds)
  • added Ted Talk video link conversion option
  • YouTube link conversion now works for iframe style embeds as well as objects
  • added ability for hackers to change the order of the post list on the tool page
  • added post comments shortcode. Includes easy way for PHP coders to fully customize the display

I was unable to figure out how to extract a Hulu video link out of their embed code since the links don’t utilize the video ID as they do for YouTube, Vimeo and TED, so I couldn’t do a Hulu embed link conversion. If you have any idea how to do this, please let me know. Also, if you know of other video providers I’ve missed, let me know.

My plan is to add a page parent shortcode, perhaps a couple other details, then release version 3.0 sometime next week. After that, I’ll move on to version 3.0 of Post List.

How to change default PDF directory in Kalin’s PDF Creation Station

In version 2.0 of Kalin’s PDF Creation Station, which I released earlier today, I moved some code around to facilitate the ability for people with a basic understanding of PHP (or even non-coders may be able to get this to work) to customize the location of the generated PDF files.

To do this, first open kalins-pdf-creation-station.php in a text editor (located in plugins/kalins-pdf-creation-station/), or enter the edit section under ‘plugins’ in your WordPress admin and find the file.

The code that designates the PDF directory currently begins on line 40 (this may change in the future, though probably not by much. Refer to code comments for updated information.) The code looks like this:

$uploads = wp_upload_dir();
define("KALINS_PDF_DIR", $uploads['basedir'] .'/kalins-pdf/');//base location of PDF files define("KALINS_PDF_SINGLES_DIR", KALINS_PDF_DIR .'singles/');//location to save individual page/post PDF files
define("KALINS_PDF_URL", $uploads['baseurl'] .'/kalins-pdf/');//the url string will be different from the directory so be careful define("KALINS_PDF_SINGLES_URL", KALINS_PDF_URL .'singles/');

The first line, of course, just grabs the upload directory object of your wordpress installation. Then in the next line we define the base location of PDF files, using the upload directory (files created on the tool page will go here). You can see the second parameter of the define() is the actual directory path. You can change this to whatever you want, even a hard-coded value. The next line defines the location to save the single PDF files (the ones generated by the link on individual pages). This is usually a sub-folder of the base directory, but again you can set it to whatever you’d like, or it can be the same as the base (if you don’t mind a long list of PDFs on your tool page).

Remember, URLs that browsers use to navigate are different from the server directory that PHP uses to modify files. Thus, the last two lines now define the proper URLs that map to the corresponding directories in the previous two lines. You can see this is easy when using the $uploads object to simply grab the [‘baseurl’] or [‘basedir’] so things match properly, but if you understand your server’s directory structure and URL mapping, you should be able to put the folders wherever you’d like.

Also remember that you will either need to copy this code into wp-config.php or re-do this every time I make an upgrade to this plugin. Beware when copying into wp-config.php that you will not have access to the wp_upload_dir() function so you will need to hard-code the paths or use functions available outside of WordPress. Also remember to add your code above the line that says “/* That’s all, stop editing! Happy blogging. */” The example below should work in wp-config.php.

The actual final PDF folder does not need to exist yet. If it doesn’t, the PDF creation script will create it automatically.


In the next section in the PHP file you’ll find some more commented-out code that looks very similar to what we just looked at.

define("KALINS_PDF_DIR", $_SERVER['DOCUMENT_ROOT'] .'/pdf/');//base location of PDF files
define("KALINS_PDF_SINGLES_DIR", KALINS_PDF_DIR);//location to save individual page/post PDF files

define("KALINS_PDF_URL", "http://" .$_SERVER['HTTP_HOST'] .'/pdf/');
define("KALINS_PDF_SINGLES_URL", KALINS_PDF_URL);//this will put all PDFs in the same folder

If un-commented to replace the previous section, this code will set the base and single PDF locations to the document root of your website in a folder called simply “pdf”.

Become a Kalin’s WordPress Plugin Beta Tester

I am currently hard at work on version 2.0 of Kalin’s PDF Creation Station WordPress plugin, which is one of my excuses for not making many blog entries lately. It occurred to me that some users may have SVN and want to get their hands on the new features a little early, before I’m completely finished testing and tweaking. It also helps me a lot to have someone using it before the new features go live.

If you have SVN, the repository locations are


http://plugins.svn.wordpress.org/kalins-post-list/ (for my Post List plugin)

http://plugins.svn.wordpress.org/kalins-easy-edit-links/ (for Easy Edit Links plugin)

Newest beta versions of these plugins should be located in the branches folder. If branches is empty, I have probably taken a break from that particular plugin project. Creation Station is my big project, the other two are comparatively simple plugins.


New stuff in the PDF Creation Station 2.0 beta:

*Added support for custom post types
*moved the code identifying the default PDF directory and URL into a few constants at the top of kalins-pdf-creation-station.pdf, so that hackers can easily change them to whatever they want. Added example code that can be un-commented to change the PDF directory to use the base domain of your site instead of the wordpress uploads directory.
*Fixed minor bug where ‘reset defaults’ on the settings page wasn’t refreshing the ‘post slug’ and ‘show on home’ checkboxes
*Added “create all” button on settings page
*Added “automatically generate PDFs on publish and update” option on settings page
*changed blockquote code so it uses the ‘pre’ tag because it was the only way to get TCPDF to actually display anything since it doesn’t want to render blockquotes or tables properly
*added post_excerpt code to use “wp_trim_excerpt”, which doesn’t appear to be functioning anymore — then changed to manually extract 250 characters from the page content
*added option to run other plugin shortcodes to both settings and tool pages
*added option to convert embedded youtube videos into a link to that video
*added ‘format’ parameter to all time shortcodes for total custom date/time formatting
*added ‘length’ parameter to the post_excerpt shortcode to set character count of the excerpt
New stuff in the works for Kalin’s Post List version 2.0:
*add format parameter for total customization of all date/time shortcodes
*add length parameter to [post_excerpt] shortcode
*add offset parameter for [item_number] shortcode to start count at something other than 1
*add ‘increment’ param for [item_number] shortcode to allow counting by something other than 1
*Custom post type support
*”None” post support (use the plugin to simply insert plain HTML)
*support for listing pages/custom posts based on parent page
*post thumbnail/featured image shortcode
*shortcode for link to page/post PDF (requires PDF Creation Station plugin)