Do you have some feature in mind that you'd love to see in Couch? Let us know.
8 posts Page 1 of 1
It would be wonderful if Couch could automatically create a downloadable PDF file of a page - or sequence of pages. Many CMSs - specially wiki-flavoured ones - have this capability. It comes in handy for various applications, such as creating downloadable receipts, or creating customised printable content for members (like certificates or stationery).

There are a couple of powerful open-source php PDF libraries out there, who do not depend on other
libraries being pre-installed or compiled - they work with php "out-of-the-box". They are:

TCPDF - extremely powerful and LGPL Licensed:
http://www.tcpdf.org

FPDF - not as full-featured, but easier to use and has an even more permissive license:
http://www.fpdf.org

The way I imagine it could work, would be through a 'pages'-like tag, which would generate a link to the downloadable pdf file. For instance, to generate a link to download an automatically generated pdf file of the receipt currently being viewed by the user:

Code: Select all
<cms:pdf masterpage='receipt.php' page_name=k_page_title />


An extra parameter could be used to set the page size of the outputted document:

Code: Select all
<cms:pdf masterpage='receipt.php' page_name=k_page_title page_size='A4' />


To output a pdf version of the entire documentation for 'version 1.4.5' of some software, set on A5 size in landscape, we could use:

Code: Select all
<cms:pdf masterpage='doc.php' folder_name='Version 1.4.5" page_size='A5' landscape=1 />


Perhaps this is something that could be considered for Couch version 2.0?,,,
+1 vote from me.

I use mPDF for this .
http://www.mpdf1.com

When mPDF is loaded you can easily create a couch template for creating a pdf.

This couch/mPDF template would look like this:

Code: Select all
<?php require_once( 'couch/cms.php' ); include("mpdf.php");?>

   <cms:template title='your PDF' hidden='1'></cms:template>

     <cms:pages masterpage='couch_page.php'>
   
      <cms:php>

              $html = '
                Here your normal couch code.....
             
              ';


//========mpdf  settings below=======================================
//==============================================================
//==============================================================



$mpdf=new mPDF('c','A4');
$mpdf->SetTitle('Your title');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

//==============================================================
//==============================================================
//==============================================================


</cms:php>

      </cms:pages>
<?php COUCH::invoke(); ?>


For sure PDF output by an couch tag would make this much easier.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Good suggestion. Shouldn't be difficult to create an addon doing this.
I have some reservations about the following though -
output a pdf version of the entire documentation for 'version 1.4.5' of some software
This, as opposed to single pages, could possibly take a very long time with the risk of the operation timing out - something that end-users always detest.
What do you say? What are your experiences?

With regards to making the PDF of a single page, I find the following quick-n-dirty approach the easiest (works with Chrome) -
1. Create a CSS for print media
2. Display a printer icon on the front-end pages that uses JS to send the page to the printer.
3. Ask the client to choose 'Save as PDF' in the printing dialog box.
KK wrote: Good suggestion. Shouldn't be difficult to create an addon doing this.


Wonderful!!!

KK wrote: I have some reservations about the following though (...)
This, as opposed to single pages, could possibly take a very long time with the risk of the operation timing out - something that end-users always detest.
What do you say? What are your experiences?


I have used some Wikis in the past that were able to output the entire 'book' as a single pdf file. The operation, if I remember correctly, did take several seconds, and the user was informed while that it may take a while.

Outputting a whole book on-the-fly is handy, for sure, but it is a very specific use-case. It is particularly useful for documentation and manuals that are constantly being updated.

The "quick-and-dirty" approach of creating a PDF from the print-dialog box is fine, if the user is savvy, but being able to have a clickable link would be truly awesome! :-)
Tomarnst wrote: +1 vote from me.

I use mPDF for this .
http://www.mpdf1.com

When mPDF is loaded you can easily create a couch template for creating a pdf.

This couch/mPDF template would look like this:

Code: Select all
<?php require_once( 'couch/cms.php' ); include("mpdf.php");?>

   <cms:template title='your PDF' hidden='1'></cms:template>

     <cms:pages masterpage='couch_page.php'>
   
      <cms:php>

              $html = '
                Here your normal couch code.....
             
              ';


//========mpdf  settings below=======================================
//==============================================================
//==============================================================



$mpdf=new mPDF('c','A4');
$mpdf->SetTitle('Your title');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

//==============================================================
//==============================================================
//==============================================================


</cms:php>

      </cms:pages>
<?php COUCH::invoke(); ?>


For sure PDF output by an couch tag would make this much easier.


I did try this code now, but i just get CAN NOT FIND PAGE. Must i have some special code between the

$html = '
Here your normal couch code.....

';
Hi,

I suppose couch can't find your template

<cms:template title='your PDF' hidden='1'></cms:template>
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Tomarnst wrote: Hi,

I suppose couch can't find your template

<cms:template title='your PDF' hidden='1'></cms:template>


Is it possible to explain abit more on how to implement this.

If i have a page view ks.php showing some info.

On this view page i wanna have the PDF link.

Must i put the code you show here in my view page, or must i make a new couch page and put code there*?

Hope you can reply on this. Realt need PDF function :)
hi,

Must i put the code you show here in my view page, or must i make a new couch page and put code there*?


Did you download mpdf ? http://www.mpdf1.com

When downloaded you could make a couch template like posted before.

change
Code: Select all
include("mpdf.php");
to the path of your mpdf file.

Now this couch template will generate a pdf , you can use your normal couch code in the html variable

Code: Select all
$html = '
                Here your normal couch code.....
              ';
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
8 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests

cron