php-pdftk icon indicating copy to clipboard operation
php-pdftk copied to clipboard

Failed to load resource.

Open phkraehling opened this issue 5 years ago • 6 comments

Im using pdftk and get an issue while im open the created pdf in safari (failed to load resource). Everything works fine on Chrome and Firefox. The problem starts while I started to use SSL.

Safari starts to load the pdf, gets grey and then stops. The pdf menu (right click) is available.

phkraehling avatar Aug 27 '20 09:08 phkraehling

@phkraehling I've moved the issue here, because this is the actual library that implements the download.

It's hard to say what's wrong here. You will have to do some debugging on your own. Just create a simple temporary file as shown in the README and then for example use curl -I to inspect the headers sent, etc. Also try to modify the download code - maybe you can make it work. Then we can see if we can implement a fix.

Also check if you have automatic compression enabled (mod_deflate on Apache or gzip on Nginx). We had some reports that this breaks the download. Also see mikehaertl/php-tmpfile#16

mikehaertl avatar Aug 27 '20 09:08 mikehaertl

@phkraehling Any news here? I don't have Safari so I can't do much. Help is very much welcome. I can also try to assist if it's unclear how to proceed.

mikehaertl avatar Sep 01 '20 11:09 mikehaertl

@mikehaertl sorry I took a look at the linked issue. But I'm not so familiar with this stuff. I changed the code to save the file instead of send. After that I display the link. But the problem is the same.

phkraehling avatar Sep 02 '20 19:09 phkraehling

So you say the problem is also when you try to download a static file from your webserver with safari (completely outside this library and even PHP)? If that's the case there's nothing to fix here.

As a summary of mikehaertl/php-tmpfile#16: The main problem in our download code is probably the Content-Length header. It tells the browser how many bytes will be sent so it can show a progress bar during the download. If this header is missing there's no progress bar. Problem is that the size of the file is not always the "real" content-length because the webserver may ZIP the response and send less bytes than what is given in the header. It seems that especially Safari doesn't like this.

mikehaertl avatar Sep 03 '20 06:09 mikehaertl

No, I dont get the Problem with a third Party pdf.

I tried it with the pdf, filled with the library.

phkraehling avatar Sep 03 '20 06:09 phkraehling

Hmm, ok then maybe the issue is really something else and not related to the download code. Sorry for moving the issue to fast.

As I can't test I'd need your help here but not sure if you find time. What you could check:

  • Do all operations of php-pdftk fail? Or only filling forms?
  • If it's related to filling forms only: Test with different PDF forms. Also test with xfdf and also fdf format ( last argg in fillForm($data, $encoding = 'UTF-8', $dropXfa = true, $format = 'xfdf'))
  • Can you reproduce the issue if you create a PDF with pdftk on the command line (without this library)?

mikehaertl avatar Sep 03 '20 07:09 mikehaertl