Giter Club home page Giter Club logo

pdfresponse's Introduction

PDF Response for Nette 2.0

  • sends template as PDF output
  • mPDF required!
  • works with Nette 2.1-dev (released on 2012-05-29)
  • without js support
  • nice api

Default file locations

libs/mPDF/
libs/netterobots.txt
libs/PdfResponse.php (anywhere)

Use

<?php

$template = $this->createTemplate()->setFile(APP_DIR . "/templates/myPdf.latte");
$template->someValue = 123;
// Tip: In template to make a new page use <pagebreak>

$pdf = new \PdfResponse($template, $this->context);
$pdf->documentTitle = "costum file name 123";

// optional
$pdf->documentTitle = date("Y-m-d") . " My super title"; // creates filename 2012-06-30-my-super-title.pdf
$pdf->pageFormat = "A4-L"; // wide format
$pdf->getMPDF()->setFooter("|© www.mysite.com|"); // footer

// now you have 3 posibilites:

// 1. render template in browser and terminate, e.g. testing
$pdf->test();

// 2. save file to server
$pdf->save(WWW_DIR . "/generated/"); // as a filename $this->documentTitle will be used
$pdf->save(WWW_DIR . "/generated/", "another file 123); // OR use a costum name

// OR in case of mail attachment, returns path to file on server
$savedFile = $pdf->save(WWW_DIR . "/contracts/"); 
$mail = new Nette\Mail\Message;
$mail->addTo("[email protected]");
$mail->addAttachment($savedFile);
$mail->send();

// 3. send pdf file to output (save/open by user) and terminate
$pdf->output();

?>

More info

pdfresponse's People

Contributors

tomasvotruba avatar

Stargazers

Jiri Musil avatar

Watchers

Jiri Musil avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.