HTML to ZPL

פרמיום
על ידי DAB Labs Inc | מְעוּדכָּן לפני 6 ימים | Video, Images
פּוֹפּוּלָרִיוּת

9.6 / 10

חֶבִיוֹן

2,188ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

Problem

Rapid account: Thanhtonyc
thanhtonyc
לפני שנתיים

I have encoded my pdf base64, but this is doesn’t work ? i don’t understand because the result said :
Parameter pdfBase64 must be base64 encoded

Rapid account: Dablabs
dablabs Commented לפני שנתיים

Hi @thanhtonyc,

I think you’re getting this error because the parameter is not set into the request correctly.

You can refer to the following sample code to call the PDF to ZPL API with PHP:

<?php
function CallAPI($width, $height, $filename) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_URL, "https://html-to-zpl.p.rapidapi.com/pdf2zpl");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);

    curl_setopt($curl, CURLOPT_HTTPHEADER, [
        "X-RapidAPI-Host: html-to-zpl.p.rapidapi.com",
        "X-RapidAPI-Key: YOUR_API_KEY",
        "content-type: application/json"
    ]);

    $pdfRaw = file_get_contents($filename);
    $pdfBase64 = base64_encode($pdfRaw);

    $data = [
        "width" => $width,
        "height" => $height,
        "pdfBase64" => $pdfBase64
    ];
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));

    $result = curl_exec($curl);

    curl_close($curl);

    return $result;
}

$zpl = CallAPI(4, 6, "test.pdf");
echo $zpl;

(replace YOUR_API_KEY with your own key from RapidAPI)

I just tested this here, and it works well.

Please let me know if this works for you, or if you need more code samples!

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות