Open tertek opened 5 months ago
/storage -- /documents/folder_id/document_id <> pdftk free and scan (upload) -- /outputs/job_id/output_id <> pdftk fill and merge (document, data) -- /tempDir
// Important: We will work with pdftk-php->getTmpFile (https://github.com/mikehaertl/php-pdftk?tab=readme-ov-file#temporary-file)
// Case create document
$fileUpload = $_FILES['pdf-upload'] $fileUpload['path']
$pdf = new Pdf($path); $pdf->operation()->execute(); $content = $pdf->getTmpFile();
$file = $this->storage-write($content);
// case create job
$document = $this->storage->read(/documents/$folder_id / $document_id); // if we cannot give abs path to pdftk_php, we need workaround wiht tmpfile, $tmpFfile = $document $document_path = $this->storage->getPath($document); $pdf = new($document_path);
$pdf->fill(..);
$size === 1 only: $pdf->execute(); $content = $pdf->getTmpFile();
$this->storage->write(/outputs/job_id/output_uid, $content);
@edenst-TPH I tested the file upload via form, also swapped the PSR7 Implementation and finally found out, that the problem was the VS Code Plugin Rest Client. It seems that some file types cannot be submitted or require a specific syntax that we are not aware of.
I have tested the same requests via Postman which worked fine. I also created commented on an issue for our currently used Rest Client: https://github.com/Huachao/vscode-restclient/issues/1235
Consequently, we can stay with nyholm/psr7 and test the API with Postman or another more stable client. I hope that the authors of vscode-restclient will fix it soon.
Added tests dae20cfbb7e1039fdb51180f77c7fe03dc62dd00
@edenst-TPH I have formalized our concept for pdftk & storage from Tuesday.
1) Initial actoion to identify form fields of a PDF. 2) Final action of filling and flattening a PDF.
1) Create Document Action: User sends multipart post request to create document.
2) Create Job Action / Create Output Action: User sends field data with Post Request as part of Create Job Action. (job creation.. triggers output creation in some kind of queue)
3) Stream Output Action
It could be useful to have a wrapper around php-pdftk that could be residing at
/src/Pdftk
analog to Filesystem. Only useful if we can save code duplication though.