Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 17

CurtisOdenericgillettejohansonlockertommyw422 +12 guests

plugin: download discussion in PDF

Hello, I need to create a plugin to allow download discussions and comments in pdf format, to create it I'll use a library called DOMPDF, this library allows you to convert HTML to PDF ... so I need to find the ID of the discussion, I am a beginner developer and still do not understand how the tree of classes, if they have more documentation on this part I would greatly appreciate if they can share...
Tagged:

Comments

  • x00x00
    Posts: 1,546 Accepted Answer
    You can already request the discussions in various formats, like rss, xml, json, etc in a RESTful (ish) way. So I would extend this for pdf.

    Presumably you will want to provide the links on the discussions list, as well one on the discussion?

    If you are a total novice programmer it might be a bit of a learning curve.

    grep is your friend.

  • Posts: 12
    yes i want to provide the links on the discussions list or one discussion, but i need to find the object or class that return ID...

    how to request in xml?
  • AFNAFN
    Posts: 70 Accepted Answer
    The U.S. Army's forum does allow people to save the discussion in PDF . I wonder if they are using Vanilla forums because theirs looks very similar. I think I will contact them and ask.

    A temporary fix, you might want to see http://pdf-ace.com and you can enable a button. The only down side is they put a watermark on the PDF file, and it make the whole page in PDF including the background(s) logo(s), but if you do not mind having a small watermark and it saving everything than that would be a good temporary fix.

    But still that would be a cool plugin.
  • Posts: 12
    thanks @AFN but i'll try to do!!
  • x00x00
    Posts: 1,546 Accepted Answer
    these are equivalent:

    http://vanillaforums.org/discussion.xml?DiscussionID=13789

    http://vanillaforums.org/discussion.xml/3789/

    so you will have

    http://vanillaforums.org/discussion.pdf/13789/some+title

    Although you could allow

    http://vanillaforums.org/discussion/13789/some+title.pdf

    this will give you a rough idea but I'm not doing all the work for you.

    <?php
    $PluginInfo['DiscussionPDF'] = array(
    'Name' => 'DiscussionPDF',
    'Description' => "DiscussionPDF",
    'Version' => '0.1',
    'Author' => 'me'
    );

    define('DELIVERY_METHOD_PDF', 'PDF');



    require_once( dirname(__FILE__)."/dompdf/dompdf_config.inc.php");


    class DiscussionPDF extends Gdn_Plugin {

    public function DiscussionController_Render_Before(&$Sender){
    $Path = explode('/',$Sender->Request->Path());
    if(substr_compare($Sender->RequestArgs[1],'.pdf',-4,4,true)===0 || substr_compare($Path[0],'.pdf',-4,4,true)===0){
    $Sender->DeliveryMethod(DELIVERY_METHOD_PDF);
    }

    if($Sender->DeliveryMethod()==DELIVERY_METHOD_PDF){
    if(substr_compare($Sender->RequestArgs[1],'.pdf',-4,4,true)===0 ){
    $FileName = $Sender->RequestArgs[1];
    }else{
    $FileName = $Sender->RequestArgs[1].'.pdf';
    }


    $Output ='<h1>'.$Sender->Data['Discussion']->Name.'</h1>';
    $Output .='<div>'.$Sender->Data['Discussion']->Body.'</div>';
    $Output .='<hr />';
    foreach ($Sender->CommentData->Result() As $Comment){
    $Output .='<div>'.$Comment->Body.'</div>';
    }
    $dompdf = new DOMPDF();
    $dompdf->load_html($Output);
    $dompdf->render();
    $dompdf->stream($FileName);

    exit;
    }


    }


    }


    You can use var_dump($Sender->Data['Discussion']); and var_dump($Comment); to see what data is available to put in the pdf.

    Use eventi plugin to see which hooks to use to add the Anchor, and or look in other plugins for help. Obviously use DOMPDF docs as well.

    I would also look into caching as this is moderate overhead.

    grep is your friend.

  • Posts: 12
    @00 thank you! I'll try :D
  • AFNAFN
    Posts: 70

    I have no idea how to go about creating a php file that makes PDFs and getting it to work.

    Can you please explain what you mean by:

    You can use var_dump($Sender->Data['Discussion']); and var_dump($Comment); to see what data is available to put in the pdf.

    Use eventi plugin to see which hooks to use to add the Anchor, and or look in other plugins for help. Obviously use DOMPDF docs as well.

    I would also look into caching as this is moderate overhead.

    Basically I'm lost.

  • x00x00
    Posts: 1,546

    @AFN I don't have the time to provide programming lessons. This is beyond what is expected with Q&A.

    If you are interested in sponsoring me, to provide a proper PDF plugin with caching, some sort of easy template system and all the rest of it I'm sure others would be grateful. Perhaps @maga and anyone else interested would like to provide their share.

    grep is your friend.

  • AFNAFN
    Posts: 70

    What do you mean by sponsoring you? You mean voting for you and the plugin? If so I would vote and sponsor you.

  • x00x00
    Posts: 1,546

    I mean pay for my time. If you are interested, then you can pay for me to develop it. Then afterwards anyone is free to enjoy.

    grep is your friend.

  • AFNAFN
    Posts: 70

    If I was to pay for your time in developing it, what would you use for the payment transaction? Would you use PayPal? Also how much would you be asking for?

  • Posts: 257

    They are called ransom plugin: x00 program the software and release it when sufficient donations are collected. Usually they are refunded if the software is not published.

    PayPal is very popular but I remind a specific site for ransom plugin: unfortunately I can't remember the url... Anyone?

  • x00x00
    Posts: 1,546

    @AFN 60GBP would be a fair price. For that I'd provide the PDF conversion infrastructure, caching to economise overhead, and a template system similar to the current one used for views.

    Paypal is fine. I can send an invoice.

    @candyman I have not heard that term, but I plan to set up something similar. Escrow account adjudication would honour the work.

    grep is your friend.

  • AFNAFN
    Posts: 70

    I do apologies, but paying 60GBP witch is 93.82 USDs is a little to high for me, nor would I be able to afford it. If it was something in the 30's than I would be more open to even take about money.

Sign In or Register to comment.