Contents
On this page

Upload Font - Plugixa PDF Vouchers for WooCommerce

POST /plugixa-pdf-vouchers/v1/fonts

Add a font, sent as multipart/form-data. The file is checked to really be a TrueType font the PDF engine can read, whatever its name says.

Needs a user with the plugixa_pdfv_manage_settings 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.

Note. Pro only: on the free plugin this route answers 404 rest_no_route.

Request

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

Request body

Content type: application/json

Field Type Required Description
regular file Yes The regular .ttf, up to 5 MB.
bold file No The bold .ttf, up to 5 MB.
label string No The name in font lists. Taken from the file when empty.

Up to 12 fonts. OpenType fonts with CFF outlines (.otf) cannot be embedded.

Responses

201 Created. data is the list of fonts, as in List Fonts.

Errors

Status Code When
401 / 403 plugixa_pdfv_forbidden The caller lacks the capability.
422 plugixa_pdfv_font No regular file (Choose the regular font file (.ttf).), not a usable TrueType font, more than 5 MB, already uploaded, 12 fonts already, or the uploads folder is not writable. The message says which.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/fonts" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -F "regular=@PlayfairDisplay-Regular.ttf" \
  -F "bold=@PlayfairDisplay-Bold.ttf" \
  -F "label=Playfair Display"
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/fonts');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_POSTFIELDS     => [
        'regular' => new CURLFile('PlayfairDisplay-Regular.ttf'),
        'bold'    => new CURLFile('PlayfairDisplay-Bold.ttf'),
        'label'   => 'Playfair Display',
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const form = new FormData();
form.append('regular', regularFile);
form.append('bold', boldFile);
form.append('label', 'Playfair Display');
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/fonts', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
  },
  body: form,
});
const { data } = await response.json();

Quick Links

Share