Contents
On this page

Preview PDF Design - Plugixa PDF Vouchers for WooCommerce

POST /plugixa-pdf-vouchers/v1/templates/preview

Make the real PDF of a design, saved or not, with a sample voucher (code PX-7KQ4-M2ZD, value 50, recipient Alex Martin, or Arabic sample names when rtl is on). This is what the editor’s live preview and the designer’s Preview PDF call. Nothing is stored.

Needs a user with the plugixa_pdfv_view capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators and shop managers get it when the plugin is activated; see Staff access.

Request

POST https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/preview

Request body

Content type: application/json

Field Type Required Description
id integer No A saved design to start from.
name string No The design’s name.
preset string No The layout. Unknown values are ignored. Defaults to classic.
paper string No A4, A5 or LETTER.
orientation string No L (default) or P.
is_default boolean No Make it the store default.
settings object No Any of the settings of Get PDF Design. Missing ones keep their value, or the layout’s starting value. A colour that is not hex is ignored.
layout object No Pro: the elements of a drag-and-drop design, checked and cleaned before it is stored.
{
  "id": 1,
  "settings": {
    "accent": "#0f766e"
  }
}

Responses

200 OK.

{
  "success": true,
  "data": {
    "pdf": "JVBERi0xLjcKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvT3V0bGluZXMgMiAwIFIgL1BhZ2VzIDMgMCBSID4+...",
    "unknown": []
  }
}
Field Type Meaning
data.pdf string The PDF file, base64 encoded. Shortened here
data.unknown string[] Placeholders in the texts the plugin does not know, which would print as typed

Errors

Status Code When
401 / 403 plugixa_pdfv_forbidden The caller lacks the capability.
500 plugixa_pdfv_preview_failed The PDF engine failed; the message says why.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/preview" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"id":1,"settings":{"accent":"#0f766e"}}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/preview');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'id'       => 1,
        'settings' => [
            'accent' => '#0f766e',
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates/preview', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ id: 1, settings: { accent: '#0f766e' } }),
});
const { data } = await response.json();

Quick Links

Share