Documentation · Technical Documentation
PDF Generation Technical Notes
This document describes how the ADP Car Market Hub plugin produces print-optimised vehicle datasheets ("exposés") that visitors can save as PDF using their browser's print dialog.
When to use this document
Read this document if you need to:
- Customise which fields appear on the printable datasheet.
- Replace the default QR-code image source with a self-hosted generator.
- Embed a link to a vehicle's printable datasheet from another page or system.
- Diagnose missing or incorrect data on the printable page.
Overview
The PDF datasheet is implemented in AS24CI\Pdf_Datasheet. It
does not generate a binary PDF on the server. Instead, it
renders a standalone HTML page (without the WordPress theme
header/footer) optimised for the browser's Print → Save as PDF
function.
This approach has two practical implications:
- The output looks identical regardless of the active theme, because the theme is bypassed.
- The browser drives the actual PDF rendering. The visitor (or the dealership team) creates the PDF locally; the server only serves HTML.
Trigger and routing
- The class registers the public query variable
as24ci_pdf. - A
template_redirectaction listens for the variable. When present and resolving to a publishedas24ci_carpost, the plugin renders the datasheet and callsexit. - The URL helper
Pdf_Datasheet::get_datasheet_url( $post_id )returnshome_url( '/?as24ci_pdf=<post_id>' ). Use this helper rather than constructing the URL by hand.
Validation rules:
- Non-numeric or zero IDs return HTTP
400with a translated "Invalid vehicle ID" message. - Missing post, wrong post type or non-published status returns
HTTP
404with a translated "Vehicle not found or not published" message.
Field selection
Pdf_Datasheet::get_allowed_fields() is the authoritative
whitelist of fields that may appear on the datasheet. Any field
not in the list is ignored, so administrators cannot show
unsupported data by manipulating the saved settings.
Currently allowed fields:
title,price,mileage,first_reg,fuel_type,transmission,power,body_type,exterior_color,doors,seats,emission_class,co2,consumption,equipment,description,location,contact.
Defaults are exposed by get_default_settings() and overlaid
onto the user's persisted PDF Manager settings, so newly added
fields receive a sensible default value.
QR code
Pdf_Datasheet::get_qr_image_url( $target_url ) returns a QR
image URL for embedding in the datasheet. The default
implementation requests a 180×180 PNG from the public goqr.me
service (https://api.qrserver.com/v1/create-qr-code/).
Operational details:
- A defensive guard returns an empty string if the target URL
contains
autoscout24.so the QR code never accidentally links to the source listing detail page. - The default URL is filterable through
as24ci_pdf_qr_image_url. Return an empty string to suppress the QR image entirely, or return your own (self-hosted) URL.
Step by step instructions
To preview a printable datasheet for a vehicle:
- Locate the vehicle in the WordPress admin or on the front-end.
- Open the URL
https://example.com/?as24ci_pdf=<post_id>in a browser. - Use the browser print dialog (
Ctrl/Cmd + P) to save the page as a PDF or send it to a printer.
To customise the visible fields:
- Open the PDF Manager admin tab.
- Toggle the fields and branding options (logo, company, address, phone, etc.).
- Save. The settings are persisted in WordPress options and merged with the defaults at render time.
To replace the QR provider with a self-hosted generator:
- Add a small mu-plugin or theme snippet that hooks
as24ci_pdf_qr_image_url, ignores the default and returns your own URL. - Verify the result in a browser before deploying to production.
Configuration reference
Field whitelist: see get_allowed_fields() above. Default
values: see get_default_settings(). The exact list of branding
and layout options exposed in the PDF Manager admin tab is
maintained server-side. Verify the current options against the
PDF Manager screen before publishing customer-facing
documentation.
Operational notes
- The renderer outputs full HTML (including
<!DOCTYPE>,<head>, inline styles) and callsexitto stop WordPress from sending its theme. Any plugin that hooks late intemplate_redirectand writes to the response after this point will not run. - Because the PDF is generated client-side by the browser, page numbering, headers/footers and paper size depend on the visitor's print settings, not the plugin.
- The QR image is fetched by the visitor's browser (or by the print engine), not by the WordPress server. If your privacy policy forbids third-party requests in printable documents, override the QR URL or suppress it entirely via the filter.
- The endpoint returns a public HTML page; do not embed confidential data in the configurable fields.
Troubleshooting
- 404 page instead of the datasheet — the post does not
exist, is not the
as24ci_carpost type, or is notpublish. Verify the ID and the post status. - 400 "Invalid vehicle ID" — the value passed in
?as24ci_pdf=was not a positive integer. - Theme styles bleed into the printable page — the renderer
bypasses the theme; if you see theme markup, another plugin is
intercepting
template_redirectbefore this one or the URL was not detected. Re-check the URL parameter and clear page caches. - QR code is missing or broken — the target URL contained
autoscout24.(suppressed for safety) or a custom filter returned an empty string. Verify the target URL and the filter implementation. - PDF differs between browsers — print rendering varies across browsers and OS. Standardise on one browser/OS for customer-facing exports if precise layout matters.