WordPress CPT x AFC: Post to PDF via SVG template fun


Assume that the starting point is a wordpress site with a Custom Page Type (CPT) for video (custom-type-video.php). This custom type uses Advanced Custom Fields (AFC) to store meta-data, and a uses a template file (single-video.php) to display the page on the website.

For example, this page: Craig Wilkins.

Given this display of information for the web, how is this translated into an archival print form?

Here is an example of an archival print form in PDF for the same page. This is a three-page PDF file, created by concatenating 3 individual pages into the final file.

The first page of this PDF file is generated via an input SVG file. This SVG file, as created by Inkscape or Illustrator, is a long and messy text file.

Simplified, it looks much more straightforward:

svg open

text open
text close

text open
text cclose

svg close

The goal is to extract the information residing in the AFC fields of the wordpress site, and strip it in to the SVG template. So, for the AFC field video_title, query the wordpress database, get a result, and strip it in to the SVG text file where afc_video_title currently resides.

Do this for all the AFC fields.Then, once done, a SVG file for this specific post will be produced.

Then, take this SVG file and transform it to a PDF file via cairosvg or inkscape.

Assume linux as the underlying OS, and utilities like ghostsript, ffmpeg, etc.


Is there a way to serialize wordpress posts that use ACF? Right now I am seeing support for Local Json, aka afc-json, which is cool and all but only describes the field group being used, not the values for a particular page.

The afc-json for data file for the above page looks like: this.

About sunglint

Comments are closed.

%d bloggers like this: