REST API : how download document in PDF

Hello,

I use the “rest api” in PHP for listing documents and download them. These documents can be in differents formats (doc, pptx, doc, …), but I want download only in PDF, like button PDF in Document management.

How can I do that ?

Thanks in advance for your answer.

0 votes

1 answers

12382 views

ANSWER



Solution trouvée !

    $client = new NuxeoPhpAutomationClient('[...]/nuxeo/site/automation');

    $session = $client->getSession($this->user, $this->pass); $answer = $session->newRequest("Blob.ToPDF")
            ->set('input', 'doc:' . $file)
            ->sendRequest();

    if (!isset($answer) OR $answer == false)
        echo '$answer is not set';
    else {
        header('Content-Description: File Transfer');
        header('Content-Type: application/pdf');
        $file = 'fichier.pdf';
        header('Content-Disposition: attachment; filename=' . $file);
        readfile('tempstream');
    }

Si ça peut aider …

0 votes