#### Dozvoljeni fajlovi: ``` jpg,jpeg,png,pdf,doc,xls,xsls,xlsx,csv,txt,html,htm,heic ``` ### Primjer koda: ``` if ($args['file']->extension() === 'jpg' || $args['file']->extension() === 'jpeg' || $args['file']->extension() === 'png') { $img = Image::make($args['file']); $img->resize(1200, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save(storage_path('app/' . $user->oib . '/' . $args['type'] . '-' . $random . '.' . $args['file']->extension())); return Storage::url($user->oib . '/' . $args['type'] . '-' . $random . '.' . $args['file']->extension()); } elseif ($args['file']->extension() === 'xls' || $args['file']->extension() === 'xsls' || $args['file']->extension() === 'xlsx' || $args['file']->extension() === 'csv' || $args['file']->extension() === 'txt' || $args['file']->extension() === 'doc' || $args['file']->extension() === 'docx') { Storage::putFileAs($user->oib, $args['file'], $args['type'] . '-temp-' . $random . '.' . $args['file']->extension()); shell_exec('curl -F "data=@' . storage_path('app/' . $user->oib . '/' . $args['type'] . '-temp-' . $random . '.' . $args['file']->extension()) . '" -F "FullSheetPreview=true" http://localhost:9980/lool/convert-to/pdf > ' . storage_path('app/' . $user->oib . '/' . $args['type'] . '-' . $random . '.pdf')); Storage::delete($user->oib . '/' . $args['type'] . '-temp-' . $random . '.' . $args['file']->extension()); return Storage::url($user->oib . '/' . $args['type'] . '-' . $random . '.pdf'); } else { Storage::putFileAs($user->oib, $args['file'], $args['type'] . '-' . $random . '.' . $args['file']->extension()); return Storage::url($user->oib . '/' . $args['type'] . '-' . $random . '.' . $args['file']->extension()); } ``` ### Bitni dijelovi `jpg, jpeg, png` ``` $img->resize(1200, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); ``` Paket: https://image.intervention.io/v2 ### Bitni dijelovi `xls, xlsx, xsls, csv, txt, doc, docx` ``` shell_exec('curl -F "data=@' . storage_path('app/' . $user->oib . '/' . $args['type'] . '-temp-' . $random . '.' . $args['file']->extension()) . '" -F "FullSheetPreview=true" http://localhost:9980/lool/convert-to/pdf > ' . storage_path('app/' . $user->oib . '/' . $args['type'] . '-' . $random . '.pdf')); ``` ### Docker install: ``` sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin sudo systemctl enable docker.service sudo systemctl start docker.service sudo systemctl enable containerd.service ``` None of these solutions worked for me. My solutions is using libre office online, I found that solution here: https://wiki.documentfoundation.org/ReleaseNotes/6.4#Full-Sheet_Previews **This part is important:** Available in the Online API The new full-sheet preview feature has also been added to the Online REST API. The command below can be used to get a full-sheet preview output of a spreadsheet document in the PDF format: `curl --insecure -F "data=@YourSpreadSheetDocument.ods" -F "FullSheetPreview=true" https://localhost:9980/lool/convert-to/pdf > out.pdf` *Please note that using the `--insecure` option is only needed while testing the feature on a local setup, and we recommended against using it for non-testing cases.* So this is how I converted XLS to PDF on the server. Here is tutorial how to install LibreOffice online with docker: https://ralph.blog.imixs.com/2021/05/07/libreoffice-online-how-to-integrate/ There is one extra step with adding `extra_params` to `docker-compose.yml` so it can accept `http` requests and allow requests from machine Here is full docker compose file ``` version: "3.6" services: libreoffice-app: image: collabora/code:6.4.8.4 container_name: libreoffice-app expose: - 9980 ports: - "9980:9980" environment: - username=admin - password=adminadmin - extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.post_allow.host[0]=.+ --o:storage.wopi.host[0]=.+ restart: always ``` When you start this service you should be able to convert XLS to PDF with this command `curl -F "data=@filename.xls" -F "FullSheetPreview=true" http://localhost:9980/lool/convert-to/pdf > out.pdf` I have spend a lot of time searching for a solution how to convert XLS to PDF without breaking single page content into multiple pages and this is the only solution that worked for me...