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
Related
I am new to using APIs on laravel. I read through PHP GuzzleHttp, but i couldnt comprehend how to corelate it with ReportingCloud. I am trying to use
ReportingCloud Docs from https://docs.reporting.cloud/docs/chapter/introduction/whatisreportingcloud . Having followed the documentation, on https://docs.reporting.cloud/docs/chapter/introduction/first page shows generation a pdf version of invoice. i still dont get the code behind downloading of the pdf file. I tried checking if my template file exist which shows postive. i try using https://docs.reporting.cloud/docs/endpoint/document/merge on merging data to your template and it works fine.
my problem is how to get those files downloaded on my computer
so, I have a setup with apache2, php5, Mysql, etc... everything seems to work alright and I'm using default directory /var/www/html.
I can upload pdfs into directory /var/www/html/uploads, and also display the pdfs uploaded into directory in list of links by using scandir(php method).
I've also checked permissions on the directory, pdf files, and /etc/mime.types.
And ofc, the files are there too. I have also tried naming my pdf files with lower case without any special characters.
The error code is 404 Not found:The requested URL /var/www/html/uploads/cv.pdf was not found on this server. When I try to download the file, by right-clicking link and downloading, i just get a broken pdf that isnt readable. However, the pdf files seem perfectly fine, since when I scp them back to my local computer and read them they're not broken at all.
Any suggestions on why I may be experiencing this error?
All suggestions and help appreciated.
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 am using a library to read XLS files which internally uses PHP's zip_open() function. When creating the files locally and then uploading to my test server everything works fine. However, when I use the XLS files downloaded from a website (normal download via browser), it does not work, instead returning Error 19 meaning that the file is not seen as a zip file, which is incorrect. Excel opens the file without problems. If I re-save the file locally as an XLSX file and then upload it, I get the same error (in this instance the file is opened by the PHP's ZipArchive class). Any ideas what the reason could be? I checked that the files are not read only, possibly some Unix permissions could be set that are not displayed in Windows? (Doubt this, as the error code indicates that the file could be accessed, but could not be identified as XLS)
Using:
Apache under Windows (WAMP)
PHP 5.4.12
It seems I had misread a line of code, the zip check is only done to determine if the XLS file is an incorrectly named XLSX file. The problem with the XLS file is that it returns no sheets when parsing, I need to look into this still. I do not know why saving the XLS file as an XLSX file (using Excel) results in an incorrect ZIP archive though, but guessing it is related.
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