Closed (fixed)
Project:
Printer, email and PDF versions
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 May 2010 at 01:18 UTC
Updated:
29 Apr 2017 at 14:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
danielbeeke2 commentedpaste: file_put_contents("sites/default/files/print/" . $filename, $pdf);
on line 170 of print_pdf.pages.inc
and make folder called print inside your files folder.
Greetings Daniel
Comment #2
alextronic commentedwow Daniel, thank you so much!
I will try that,
Alex
Comment #3
jcnventuraComment #5
Becker-and-Becker commentedI seem to get a blank file (0 bytes) in the files/print folder when using dompdf, i have added the above code to line 170, but I dont get any output generated to the file. Please could you assist.
Comment #6
scottatdrake commentedJust a note for the next person....
You can achieve the same result using the TCPDF library by adding the following lines to the end of the function _print_pdf_tcpdf in print_pdf.pages.inc (line 305 or so):
Comment #7
scottatdrake commentedSo... is there any function that would allow me to simulate clicking on the printpdf link for a given node? I've been wading through these controller functions for some time without success.
Comment #8
cbessire commentedI added this line
file_put_contents("sites/default/files/print/" . $filename, $pdf);
on the line 170.
I get the same problem as 3degreesdesign... 0k bite file.
Is there a fixed
I'am using DOMPDF and I can't change
Comment #9
cbessire commentedFound a trick to save to the server :
adding those lines juste after $dompdf->render(); (line 205)
$pdfoutput = $dompdf->output();
$filepath = "sites/default/files/print/" . $filename .".pdf";
$fp = fopen($filepath, "w");
fwrite($fp, $pdfoutput);
fclose($fp);
Comment #11
chipway commentedHas anybody managed to save pdf files to server sites/default/files/print folder with wkhtmltopdf ?
Following #1 + #9, i can do it with dompdf, but i would like to do the same with wkhtmltopdf.
Thank you
Comment #12
Apfel007 commentedsub
Comment #13
bogdan1988 commentedHi, everyone, I just want to propose you solution without hacking print-email-pdf. We can simply create appropriate directories and get pdf file content by file_get_contents() and then using file_put_contents() to put file in appropriate dir.
Comment #14
PeterX-dupe commentedHello Bogdan where and how I have to install the Snipsel. Greeting Peter
Comment #15
jcnventuraMost of this functionality is already in the module.. There's a PDF cache mechanism that saves a copy of the PDFs in the filesystem.
Comment #16
jcnventuraNo further info in more than two weeks. Closing the issue.
Comment #17
yevgeny.ananin commentedHi. Am I missing something? Is there a config setting to enable the cache mechanism that saves a copy of the PDFs to the filesystem? If not I'm going to give comment #13 a try.
EDIT:
Following the advice in comment #13 worked for me
Comment #18
5t4rdu5t commentedHere's a code snippet that works. Generates PDF file contents from a Drupal path and saves it to the temporary directory.
Hope it helps someone...
Comment #19
gans2910 commentedHi,
I tried code from comment #18. It creates pdf and save it on server. But it create other html as well. Such as it prints other tabs like Edit, Delete, Likes. Also it prints console errors at the last page of pdf.
I also tried comment #13. But file_get_contents with printpdf url return nothing.
Any idea why this is not working?
Thanks,
gans
Comment #20
Johnny Koh commentedHi All,
I'm trying #1 but the PDFs are not saving. Did I add the code wrongly?
Comment #21
balian0303 commentedI worked out out by introducing a hook.
Comment #22
sj.suraj commentedI am using dompdf for generating pdf in Drupal 7. its working very fine on localhost. But its not working on online server. There it is not generating page also. It just reload the page again. Anybody please help me.
Comment #23
tassaf commentedshould be added in line 167
if (!empty($pdf)) {
+ file_put_contents("sites/default/files/test.pdf", $pdf);
Comment #24
Michael Langbein commentedComment #13 by Bogdan is really the best solution.
Just make sure that the permissions for going to that link are set correctly - this is what I was struggling with at first :)