<?php
    include "../db/headerApi.php";
    include "../db/connection_main.php";
    require_once '../vendor/autoload.php';

    $json = file_get_contents('php://input');
    $data = json_decode($json);
    $filePath = "../../webfiles/pdpa/".$data->userid."(".$data->lang.").pdf";

    if ($data->signed != "Y") {
        $filePath = "../files/PDPA-".$data->lang.".pdf";
    }

    $type = pathinfo($filePath, PATHINFO_EXTENSION);
    $datapdf = file_get_contents($filePath);
    $base64 = base64_encode($datapdf);

    print json_encode($base64);
?>