Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Customising PDF output

Customising PDF output 2 Jahre 7 Monate her #82905

  • ian
  • ians Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 3
  • Karma: 0
Hello,

I'm looking for a way to customize pdf report from survey generated by Lime.

in
/admin/statistics_function.php

are
* pdf Config
*/
if($outputType=='pdf')
{
require_once('classes/tcpdf/config/lang/eng.php');
global $l;
$l = $statlang->gT("Page",'unescaped');
require_once('classes/tcpdf/mypdf.php');

// create new PDF document
$pdf = new MyPDF();
$pdf->SetFont($pdfdefaultfont,'',$pdffontsize);

$surveyInfo = getSurveyInfo($surveyid,$language);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('LimeSurvey');
$pdf->SetTitle('Statistic survey '.$surveyid);
$pdf->SetSubject($surveyInfo);
$pdf->SetKeywords('LimeSurvey, statistics, Survey '.$surveyid.'');
$pdf->SetDisplayMode('fullpage', 'two');

// set header and footer fonts
$pdf->setHeaderFont(Array($pdfdefaultfont, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array($pdfdefaultfont, '', PDF_FONT_SIZE_DATA));

// set default header data
// the path looks awkward - did not find a better solution to set the image path?
$pdf->SetHeaderData("statistics.png", 10, $statlang->gT("Quick statistics",'unescaped') , $statlang->gT("Survey")." ".$surveyid." '".FlattenText($surveyInfo,true,'UTF-8')."'");


// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);
}

I didn't find any other links referring to pdf.

So, is there a template to modify pdf output, or only solution is to modify code above ?

I need to nest some picture in footer, or header if footer isn't available.

Any idea how to do it?
Letzte Änderung: 2 Jahre 7 Monate her von ian.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Customising PDF output 2 Jahre 2 Monate her #89734

  • zunch2000
  • zunch2000s Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 7
  • Karma: 0
Hi Ian,

I have the same problem.
Did you solve the problem?
Can you help me on that issue?
Can you refer me to someone how can solve my problem?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Customising PDF output 2 Jahre 2 Monate her #89752

  • helper
  • helpers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 126
  • Dank erhalten: 18
  • Karma: 0
Fairly common issue - please vote for my suggestion and/or make a suggestion at: ideas.limesurvey.org/ideatorrent/idea/436/
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Customising PDF output 2 Jahre 2 Monate her #89756

  • zunch2000
  • zunch2000s Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 7
  • Karma: 0
hi
i just voted for you!
in the meanwhile, if you have any idea please i need guidance here.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Customising PDF output 2 Jahre 2 Monate her #89757

  • helper
  • helpers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 126
  • Dank erhalten: 18
  • Karma: 0
Let me start by saying that I am using LimeSurvey Version 2.00+ Build 121204 - and my workarounds are what many would call hacks (not to mention my primary language is Java)...

Now that we have that out of the way the place that you may want to start is ...applications/controllers/PrintanswersController.php

This is where both the printed version and the pdf start.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Customising PDF output 9 Monate 1 Woche her #108966

  • jboogie21
  • jboogie21s Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 17
  • Karma: 0
I'm reviving this old thread to see if anyone has managed anything in relation to formatting "Print answers" and "Printing to PDF".

This clearly has been an issue for a while, just wondering before I (or someone from my IT dept) starts hacking things to pieces.

jason
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Customising PDF output 5 Monate 2 Wochen her #112324

  • tammo
  • tammos Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 62
  • Dank erhalten: 5
  • Karma: 1
Probably your problem has been solved, but just as a reminder for people that landed on this page through a search engine:

since the PDF output from LimeSurvey is a bit hard to alter, we use MPDF implemented in the backend. This works great, but you have to do some styling yourself.

www.mpdf1.com/mpdf/index.php

Tammo ter Hark
Tools for Research
Haarlem/Amsterdam, The Netherlands

Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Ben_V

Customising PDF output 5 Monate 2 Wochen her #112328

  • Ben_V
  • Ben_Vs Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 1209
  • Dank erhalten: 283
  • Karma: 82
Probably Another "small step" ;)
Thank you Tammo...
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Customising PDF output 5 Monate 2 Wochen her #112383

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6886
  • Dank erhalten: 925
  • Karma: 275
tammo schrieb:
Probably your problem has been solved, but just as a reminder for people that landed on this page through a search engine:

since the PDF output from LimeSurvey is a bit hard to alter, we use MPDF implemented in the backend. This works great, but you have to do some styling yourself.

www.mpdf1.com/mpdf/index.php
Hi tammo,

mpdf seems great, if you have some solution that can be included in LimeSurvey core , you can create a pull request in our github.

Denis
PS: update our 'print pdf' to mPDF can be great with mpdf1.com/manual/index.php?tid=254 and include some pdf.css file in template (admin and public).
Letzte Änderung: 5 Monate 2 Wochen her von DenisChenu.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Customising PDF output 3 Wochen 4 Tage her #116895

  • Sweden
  • Swedens Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 72
  • Dank erhalten: 1
  • Karma: 2
tammo schrieb:
since the PDF output from LimeSurvey is a bit hard to alter, we use MPDF implemented in the backend. This works great, but you have to do some styling yourself.

www.mpdf1.com/mpdf/index.php


I send a private message to Tammo, but I might as well post my question here so other people can benefit from any answers I might receive. And maybe someone else knows the answer to my question so here it is:

How can I implement MPDF so it can create a PDF file at the end of the survey? My goal is that the survey participants answer a couple of questions and based on their answers they will receive some advice when they click the NEXT button (for that I use "Text display" as question type where I use "Relevance equation"). I would like to have a "Save this page as PDF" button on that page. MPDF looks great, but I haven't got a clue how to make it work. I have used a couple of days trying to figure out how I can make it work, but I really don't know much about php etc. How do you send the php to MPDF (can it use the content in a div and then make a pdf out of it??). Also, where do I insert code without creating a big security hole?

Any help would be appreciated - even a few hints and tips would be a great help. Thanks.

PS: The code below is something I found while searching for a solution, but I don't know how to customize it so it will work.
<?php
$content = get_include_contents('??????');
include('./mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML($content);
$mpdf->Output(example.pdf,'D');   exit;
 ?>
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.217 Sekunden
Donation Image