I'm using Filepicker.io to upload PDFs to my application. I have all those URLs and now I am trying to merge some of those PDFs using the PDF Tool Kit PHP library. It was not working for me so I ran some tests using the "file_exists" on PHP and it kept returning false.
I think this has to do with the fact that the URL does not have a ".pdf" extension at the end. This is what they look like: "https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1"
Does anyone know how I can pull the PDF using PHP in order to merge those files using the PDF Toolkit Library?
Thanks!
Alain F.
file_exists doesn't work with URLs, only with local files. Instead download the file to the temp dir using the copy command.
If the file can't be downloaded, the copy command will return false.
$exists = copy('https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1', '/tmp/example.pdf');
if (!$exists) throw new Exception("PDF could not be downloaded");
Use the downloaded file in the PDF Tool Kit.
EDIT: This does not solve this particular problem but does address the theory that it didn't work because "the URL does not have a ".pdf" extension at the end."
You can add things to the end of the filepicker URL with a trailing +
The following urls are equivalent:
https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1
https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1+name.pdf
Related
I tried using pdftk library from mikehaertl. I installed the composer file needed. But no pdf file is being generated. I also tried using the exact codes in mr.digital yt vid, still no file. Ive tried tweaking some codes like removing the access, uninstalling the lib and reinstalling it again.
You can check here the exact codes i tried using.
https://github.com/mrdigitalau/PHP-PDFTK-Tutorial
I removed the request methon from generate PHP file and define access with the generatePDF file from classes. Any help? Thankyou
Generate a downloadable PDF file and it should be automatically saved in the folder that is declared in the codes as well
Im working on a Laravel backend and I need to edit a PDF file allocated in a s3 bucket. When I try opening the PDF with $pdf->setSourceFile($url) I get an error saying Given stream is not seekable!
I can get the file contents using Storage::disk(ENV('FILESYSTEM'))->url($url);, and return it to the front end and that works fine, so I know the path and the permissions are correct. I would like to the content to the setSourceFile($contents) method, intead of the url. is there any way to do this?
By the way, Im using the Laravel filesystem
Edit: I have tried copying the file from s3 to the server and then open it with PDF. I couldn't reach it, but I don't think that's a good way to do it.
First of all: You cannot edit a PDF document with FPDI
As the error message says, the source stream needs to be seekable which seems not be the case with the stream wrapper you're currently using.
You should download the file and create a reader instance of it:
$pdf->setSourceFile(StreamReader::createByString($pdfString));
I am using laravel framework version 5.1. My requirement is to upload multiple files of types doc, docx, pdf and to save this file as a single PDF file. I have found packages that can combine/edit PDF files. But is there any library/package available for laravel to do this with doc/docx files too?
I found that LibreOffice allows command line conversion using the LibreOffice conversion engine (which DID preserve the formatting like I wanted and generally worked great).
libreoffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf
But I didn't have admin rights on my host's web server.
Then I ran across a cool project made by a Ph.D. student (Philip J. Guo) at Stanford called CDE(Code Data Environment). In short, it allows one to avoid dependency hell by copying all the files used when you run certain commands, recreating the linux environment where the command worked. I was able to use this to run LibreOffice without having to resort to someone's portable version of it, and it worked just like it did when I did it on Ubuntu with the command above, with a tweak: I needed to run the wrapper of LibreOffice the CDE generated.
I don't know of a catch all package to do this but as i can not comment yet (just joined), here is how i would do it.
upload the files using using your form and controller do your validation, storage etc.
Then pass an array of the paths to the files you have uploaded to a blade template and embed them on the page depending on the file type.
This package
https://github.com/barryvdh/laravel-dompdf
Can convert a html template to a pdf.
Hope it points you in the right direction
$pdf = App::make('dompdf');
$files = ['your file paths'];
$pdf->loadView('template.path', ['files' => $files])->setPaper('A4')->setOrientation('portrait');
return $pdf->stream('download.pdf');
I wonder how I can add tags to a PDF document using PHP. The idea is that I can search for a document using the tag that I assigned it previously.
Your hint is exiftool to manipulate PDF tags. There is a PHP wrapper/driver for it. BIG NOTE that it is not recommended for production.
You have to install pdf to image converter on your server, here is the settings:
Please update the server with this package, so the conversion functionality works.
you can found the files i used on local server from
i used on windows using follwing instructions
Install gs909w32.exe (http://downloads.ghostscript.com/public/gs909w32.exe )
Install ImageMagick-6.8.9-4-Q16-x64-dll.exe (Link )
paste "php_imagick.dll" file in C:\wamp\bin\php\php5.4.3\ext\
include extensions= php_imagick.dll in php.ini file
It will convert your .pdf document to images (1 image/1 page), then you can tag....
I am trying to download some files. I have written a php script that can gather all of the address of the pdf files I need to download into a array but the file names on that server are odd. How does one go about downloading pdf files with php?
you can try (if I understand your question correctly)
file_put_contents('/your/file/name.pdf',
file_get_contents('http://www.example.com/oddFile.pdf'))
Check out the file or file_get_contents functions. It can take URLs as well as local filenames.
http://www.php.net/manual/en/function.file.php
http://www.php.net/manual/en/function.file-get-contents.php