I have created a view that takes as an argument the name of a user and prints out his profile.
Now when a user is registered I have a rule and I save the pdf to the server before sending it as an attachment with Mime Mail.

I started testing it on a windows pc with xampp and it worked great.
I then moved it to the production server (linux) and I get a blank page with this error:
TCPDF ERROR: Unable to create output file: sites/default/files/private/registration/pdf/oneo/test.pdf
I went back to my local site and I get the same error. I don't know what might have changed. Is there any way to get some debug info? I can't find anything on logs.

The only thing logged by drupal is this:
Warning: fopen(sites/default/files/private/registration/pdf/oneo/test.pdf) [function.fopen]: failed to open stream: No such file or directory in TCPDF->Output() (line 8629 of ...\sites\all\libraries\tcpdf\tcpdf.php).

I have already made sure the folder path is right.
I made sure its a relative path.
I checked if any fopen, or php safe mode were enabled on the server
I checked the folder permissions.
The view is working.
I even tried other folders (just in case because I am trying to save it to the private filesystem)

Nothing works. And what's weird is I can't make it work on the local site anymore.
The only relevant issue I have found is on this comment and has to do with folder permissions [#comment-5366756]
I would be grateful if you could point me at least to the right direction as to where to look for the problem.

Comments

cadoughe’s picture

I'm having the same problem. Following.

hanspln’s picture

I'm also getting this one, anyone found out how to fix?

hanspln’s picture

I'm also getting this one, anyone found out how to fix?

hanspln’s picture

Not exactly sure what happened, but now it works.

The paths for me are as follows:
Save pdf:
sites/default/files/[replacement]
Send PDF
sites/default/files/[replacement].pdf

Note the lack of extension on Save.

hanspln’s picture

When using private files it seems I had to append the PDF extension to both, so:

Save pdf:
../private/savepdf/[replacement].pdf
Send PDF
../private/savepdf/[replacement].pdf

lsolesen’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

PhilY’s picture

private://[pdf-folder]/[filename].pdf allows for me to follow the private folder setting whether I am using the dev or the production website.

maxplus’s picture

Hi,
I had to downgrade my TCPDF version because with the version I was working with (6.2.6), it was impossible to get it working.

Maybe a newer version also works, but now I'm using 6.0.020.
My path is set like this

sites/default/files/pdf

The permissions on the pdf folder are 755

rakesh.nimje84@gmail.com’s picture

#9 worked for me.
Thanks maxplus.

massiws’s picture

Hi,
I also getting this one on a (Linux) local machine.
My download path: sites/default/files/my_pdfs - TCPDF version: 6.2.11;
Downgrade TCPDF to 6.0.020 (as suggested in #9) don't fix the problem.
I found a workaround:
1) change owner and group of my_pdfs folder to www-data (previously I created it with mkdir, so it has my user and group);
2) edit tcpdf_static.php file:

public static function fopenLocal($filename, $mode) {
	// if (strpos($filename, '://') === false) {
	// 	$filename = 'file://'.$filename;
	// } elseif (stream_is_local($filename) !== true) {
	// 	return false;
	// }
	// return fopen($filename, $mode);
		return fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
}

as described here.

Hope this helps,
Max.

maxplus’s picture

Hi,

for me using TCPDF 6.2.13 I changed my tcpdf_static.php file like this to be able to write a pdf file:

public static function fopenLocal($filename, $mode) {
	//	if (strpos($filename, '://') === false) {
	//		$filename = 'file://'.$filename;
	//	} elseif (stream_is_local($filename) !== true) {
	//		return false;
	//	}
		return fopen($filename, $mode);
	//return fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
	}
amirimran’s picture

I had the same problem and taking help from #11 i was able to fix this without hacking tcpdf library. I am on tcpdf 6.2.13
(example data from Ubuntu 16.04, with a project folder name mysite and user devel inside group devel, i am assuming apache is running with www-data group and user)

1. Check who owns the project folder in question.
ls -ld /var/www/html/mysite

Lets assume that is devel inside group devel

2. Add www-data user to group devel
sudo adduser www-data devel

3. Update owner and folder permissions for www-data

sudo chown -vR :www-data /var/www/html/mysite/

sudo chmod -vR g+w /var/www/html/mysite/

lephleg’s picture

Step [3] of #13 solved this for me. (TCPDF v6.2.12)