PDF Content get changed From Application view to downloaded files - php

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!!

Related

Laravel - edit pdf with FPDF with a soruce file from s3

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));

dynamically give pdf path in pdf.js using php mysql

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!

Is embedding a link to a PHP program in a CSS file safe?

While working on a website I inherited, I was trying to find a background image loaded by the page because it's not stored in the media manager or in the theme's image directory. When I used Chrome's browser inspector to try and download the image, Chrome downloaded a PHP program instead. So, I took a closer look at the CSS file I was inspecting, and found this:
section#headerimg{height:600px;position:relative;z-index:-1;background:url(../images/headers/rotate.php) no-repeat 0 0;background-size:cover;/* Article
Being that this makes it easy to download the PHP source file that calls the image to be displayed rather than the output (the background image), is this a safe thing to do in a CSS file? Is it even valid CSS? Note that this is not a PHP file that generates the CSS file, it's a static CSS file.
chris85 is correct. It turns out my client's hosting provider did not have the permissions set right on my client's account. I contacted the hosting provider and they corrected the issue. Now the referenced PHP file executes as it should. Thank you for your help.

Why some pdf files are not recognized as pdf in android devices

I am accessing this URL with my android device and the pdf download starts downloading automatically, without asking me to open the pdf vieth the pdf viewer.
This works in other websites.
I am the developer of the website. I set up the header to application/pdf. Any idea what can be the problem? Thank you.
Ok, I identified the problem and found the workaround.
It seems that the native android browser in not very intelligent. In fact, when a file is dowmloaded, the header of the file is not checked. The browser checks only the extension of the file in the url.
In my url, at the end we had /pdf, so no extension was found. By renaming the end of the url to xxx.pdf, the browser was able to recognize the file as a pdf.

Save cakeresponse to server

im using CakePHP 2.1 and DOMPDF to generate some reports the process is working fine but i can only promt the user to download the file from the controller action using:
$this->response->download('filename');
or open the file in the browser
i am not using any dompdf function to generate the files, the only thing different from accesing a normal view is that i generate the files by adding '.pdf' to the urls like:
mysite.com/controller/action.pdf
I have a folder for my controller view files (one view file for each action in the controller) and inside that folder i have another folder called pdf where i have put the view file for the action that is generating the pdf file, this view file is a normal .ctp file with all the html/php needed to correctly generate the pdf file
The thing i want its to be able to save the generated pdf file to the server so that i can setup a cronjobs to send this files daily at night. The generated file is rendered as a pdf file and can be handled with cakeresponse.
thank you
Well, instead of sending the content just store the file on disk and keep a reference to that file so that you know the file belongs to a certain record.
When requested get the file from disk and send it. I don't get your problem here? Either this is a "write the code for me" style question or are you simply asking for that concept?

Categories