I created a pdf using FPDF in php. I want to have the website automatically upload this pdf to Google Drive through the API. However, seeing that this is not a file on the PC, can I turn the pdf into a url?
For instance, something like: http://www.pdf995.com/samples/pdf.pdf
Is this possible?
I think what you are looking for is
$fpdf->Output('F', 'Path to file');
It can be found in the documentation.
Save the file to a publicly accessible folder and echo the url to the user.
Related
I am using TCPDF to generate the PDF, when I open a PDF file on my browser within the application use, with URL viewDocument.php look like these,
And when it is downloaded, view downloadDocument.php
Not understanding why this problem is occurring, really do not understand.Please Help!!
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've developed a small application in php and mysql, where i'm uploading pdf and moving file to UPLOADS folder and storing path in database.
But in viewing after passing path i'm not able to open pdf on browser.
I've uploaded PDF.JS files in my folder aswel.
Below are my testing urls.
http://www.farukhzama.com/fileupload/index.php
http://www.farukhzama.com/fileupload/view.php
Your link is :
http://www.farukhzama.com/fileupload/viewer.html?file=uploads/47920-ombudsman-acknowledgement.pdf at view.php file, which is wrong path to get the pdf file.
Give it right path like this => http://www.farukhzama.com/fileupload/uploads/47920-ombudsman-acknowledgement.pdf
Thanks!
I am using the dompdf library to create my table based PDF and I can view it online or I can have it download to the users folder of choice.
But what I would like to do is have it save it to the remote server( i dont need it to be save to the users PC), like an automatically upload script that would create the file then upload it to the remote server, so i can then use it within my application later on.
is it possible to point the $_FILES["file"] script say so fetch the php page that creates the pdf and it then uploads it from there.
You can do one thing like below which i am doing for my application. First create a folder in your server under the root directory for example. Then change read write permissions to that folder using chmod command.
Then get all the code in $html string.
$dompdf->load_html($html);
$dompdf->render();
$pdf = $dompdf->output();
$file_location = $_SERVER['DOCUMENT_ROOT']."app_folder_name/pdfReports/".$pdf_name.".pdf";
file_put_contents($file_location,$pdf);
Where pdfReports is the folder which i created to save all the pdf's. You can change to your folder name.
Quoted from PHP manual :
A URL can be used as a filename with this function if the fopen
wrappers have been enabled.See fopen() for more details on how to
specify the filename. See the Supported Protocols and Wrappers for
links to information about what abilities the various wrappers have,
notes on their usage, and information on any predefined variables they
may provide.
Source: http://php.net/manual/en/function.file-put-contents.php
Is it feasible to create the PDF directly on the server instead, and let the client download it if he needs it? If so, you could use wkhtmltppdf to convert any HTML page into a PDF on the server and save it and/or stream it to the client.
http://code.google.com/p/wkhtmltopdf/
Can't you use the FTP functions of PHP ?
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