Example #1
0
 /**
  *  Save PHPExcel to file
  *
  *  @param     string     $pFilename   Name of the file to save as
  *  @throws    PHPExcel_Writer_Exception
  */
 public function save($pFilename = NULL)
 {
     $fileHandle = parent::prepareForSave($pFilename);
     //  Default PDF paper size
     $paperSize = 'LETTER';
     //    Letter    (8.5 in. by 11 in.)
     //  Check for paper size and page orientation
     if (is_null($this->getSheetIndex())) {
         $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
     } else {
         $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
     }
     $this->setOrientation($orientation);
     //  Override Page Orientation
     if (!is_null($this->getOrientation())) {
         $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation();
     }
     $orientation = strtoupper($orientation);
     //  Override Paper Size
     if (!is_null($this->getPaperSize())) {
         $printPaperSize = $this->getPaperSize();
     }
     if (isset(self::$_paperSizes[$printPaperSize])) {
         $paperSize = self::$_paperSizes[$printPaperSize];
     }
     //  Create PDF
     $pdf = new mPDF();
     $ortmp = $orientation;
     $pdf->_setPageSize(strtoupper($paperSize), $ortmp);
     $pdf->DefOrientation = $orientation;
     $pdf->AddPage($orientation);
     //  Document info
     $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
     $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
     $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
     $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
     $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
     $pdf->WriteHTML($this->generateHTMLHeader(FALSE) . $this->generateSheetData() . $this->generateHTMLFooter());
     //  Write to file
     fwrite($fileHandle, $pdf->Output('', 'S'));
     parent::restoreStateAfterSave($fileHandle);
 }
Example #2
0
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
require_once 'inc/common.php';
require_once ELAB_ROOT . 'inc/locale.php';
require_once ELAB_ROOT . 'vendor/autoload.php';
// Check id is valid and assign it to $id
if (isset($_GET['id']) && is_pos_int($_GET['id'])) {
    $id = $_GET['id'];
} else {
    die(_("The id parameter is not valid!"));
}
// check the type
if ($_GET['type'] === 'experiments' || $_GET['type'] === 'items') {
    $type = $_GET['type'];
} else {
    die(_("The type parameter is not valid."));
}
// do the pdf
$pdf = new \Elabftw\Elabftw\MakePdf($id, $type);
$mpdf = new mPDF();
$mpdf->SetAuthor($pdf->author);
$mpdf->SetTitle($pdf->title);
$mpdf->SetSubject('eLabFTW pdf');
$mpdf->SetKeywords($pdf->tags);
$mpdf->SetCreator('www.elabftw.net');
$mpdf->WriteHTML($pdf->content);
$mpdf->Output($pdf->getFileName(), 'I');
Example #3
0
 /**
  * Set PDF Meta Key Words.
  *
  * @param array $words  The page key words
  *
  * @return PdfInterface The current instance
  */
 public function setMetaKeywords(array $words) : PdfInterface
 {
     $this->setProperty('metaKeywords', array_merge($this->metaKeywords, $words));
     $this->mpdf->SetKeywords(implode(', ', $this->metaKeywords));
     return $this;
 }
Example #4
0
include "../mpdf-6.1.2/mpdf.php";
$html_data = file_get_contents("body-ar.html");
$style_data = file_get_contents("style-ar.css");
// Create new PDF with font subsetting, 210mm wide, 297mm high
$mpdf = new mPDF('s', array(210, 297));
// Make it a double sided document with 4mm bleed
$mpdf->mirrorMargins = 1;
$mpdf->bleedMargin = 4;
// Set right to left text
$mpdf->SetDirectionality('rtl');
// Generate the table of contents from H3 elements
$mpdf->h2toc = array('H3' => 0);
// Write the stylesheet
$mpdf->WriteHTML($style_data, 1);
// The parameter 1 tells mPDF that this is CSS and not HTML
// Write the main text
$mpdf->WriteHTML($html_data, 2);
// Set the metadata
$mpdf->SetTitle("An Example Title");
$mpdf->SetAuthor("Cicero");
$mpdf->SetCreator("mPDF 6.1.2");
$mpdf->SetSubject("Lorem Ipsum");
$mpdf->SetKeywords("Lorem, Ipsum");
// Generate the PDF file
$mpdf->Output('arabic.pdf', 'F');
// Stop mPDF
exit;
?>


Example #5
0
<?php

# THIS ONE DOES NOT HAVE AddPageByArray ANY MORE :-)
include "../mpdf.php";
$html_data = file_get_contents("body.html");
$html = substr($html_data, 12, strlen($html_data) - 27);
$style_data = file_get_contents("style_current.css");
$frontmatter_data = file_get_contents("frontmatter_current.html");
// Create new PDF with font subsetting, 234mm wide, 297mm high
$mpdf = new mPDF('s', array(234, 297));
// Make it DOUBLE SIDED document with 4mm bleed
$mpdf->mirrorMargins = 1;
$mpdf->bleedMargin = 4;
$mpdf->WriteHTML($style_data, 1);
$mpdf->WriteHTML($frontmatter_data, 2);
$mpdf->WriteHTML($html, 2);
$mpdf->SetTitle("An Example Title");
$mpdf->SetAuthor("Aco");
$mpdf->SetCreator("Booktype 2.0 and mPDF 6.0");
$mpdf->SetSubject("History");
$mpdf->SetKeywords("Middle Ages, Jet Travel");
$mpdf->Output();
?>


$individual = file_get_contents("individual-contributor-license-agreement.html");
$style_data = file_get_contents("contributor.css");
$entity = file_get_contents("entity-contributor-license-agreement.html");
// Create new PDF with font subsetting, 210mm wide, 297mm high
$mpdf = new mPDF('s', array(210, 297));
// Make it DOUBLE SIDED document
$mpdf->mirrorMargins = 1;
$mpdf->WriteHTML($style_data, 1);
$mpdf->WriteHTML($individual, 2);
$mpdf->SetTitle("Booktype GmbH Individual Contributor License Agreement");
$mpdf->SetAuthor("Booktype GmbH");
$mpdf->SetCreator("mPDF 6.0");
$mpdf->SetSubject("Booktype Contributor Agreements");
$mpdf->SetKeywords("Booktype, AGPL, GitHub");
$mpdf->Output("individual-contributor-license-agreement.pdf", 'F');
// Create new PDF with font subsetting, 210mm wide, 297mm high
$mpdf = new mPDF('s', array(210, 297));
// Make it DOUBLE SIDED document
$mpdf->mirrorMargins = 1;
$mpdf->WriteHTML($style_data, 1);
$mpdf->WriteHTML($entity, 2);
$mpdf->SetTitle("Booktype GmbH Entity Contributor License Agreement");
$mpdf->SetAuthor("Booktype GmbH");
$mpdf->SetCreator("mPDF 6.0");
$mpdf->SetSubject("Booktype Contributor Agreements");
$mpdf->SetKeywords("Booktype, AGPL, GitHub");
$mpdf->Output("entity-contributor-license-agreement.pdf", 'F');
?>


Example #7
-1
function pdf_echo($filename = "")
{
    global $__pdf_html, $__pdf_orientation, $__pdf_wm_text, $__pdf_wm_img, $__pdg_pgn_pos, $__pdf_title, $__pdf_subject, $__pdf_author, $__pdf_creator, $__pdf_keywords, $__pdf_wm_talpha, $__pdf_wm_font, $__pdf_wm_ialpha, $__pdf_pgn_text, $__pdf_pgn_pos, $__pdf_pgn_oalign, $__pdf_pgn_ealign, $__pdf_pgn_show, $__pdf_pgn_fcolor, $__pdf_pgn_ftype, $__pdf_pgn_fsize, $__pdf_pgn_fstyle, $__pdf_pgn_lstyle, $__pdf_pgn_lwidth, $__pdf_pgn_lcolor, $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f;
    require_once dirname(__FILE__) . "/__RES__/mpdf.php";
    $pdf = new mPDF("th");
    $pdf->useOddEven = 1;
    if ($__pdf_pgn_show) {
        $dv1 = "<div style=\"{$__pdf_pgn_fcolor};width:auto;text-align:";
        $dv2 = ";{$__pdf_pgn_ftype}{$__pdf_pgn_fsize}{$__pdf_pgn_fstyle}";
        $dv3 = "style:{$__pdf_pgn_lstyle};";
        $dv4 = "width:{$__pdf_pgn_lwidth};";
        $dv5 = "color:{$__pdf_pgn_lcolor};";
        $dv6 = "\">{$__pdf_pgn_text}</div>";
        if ($__pdf_pgn_pos == "TOP") {
            $align = $__pdf_pgn_oalign;
            $border = "border-bottom-";
            $pgh_o = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
            $pdf->DefHTMLHeaderByName("ho", $pgh_o);
            $align = $__pdf_pgn_ealign;
            $pgh_e = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
            $pdf->DefHTMLHeaderByName("he", $pgh_e);
            $pdf->AddPage($__pdf_orientation, '', '', '', '', $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f, 'html_ho', 'html_he', '', '', 1, 1, 0, 0);
        } else {
            if ($__pdf_pgn_pos == "BOTTOM") {
                $align = $__pdf_pgn_oalign;
                $border = "border-top-";
                $pgf_o = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
                $pdf->DefHTMLFooterByName("fo", $pgf_o);
                $align = $__pdf_pgn_ealign;
                $pgf_e = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
                $pdf->DefHTMLFooterByName("fe", $pgf_e);
                $pdf->AddPage($__pdf_orientation, '', '', '', '', $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f, '', '', 'html_fo', 'html_fe', 0, 0, 1, 1);
            }
        }
    } else {
        $pdf->AddPage($__pdf_orientation);
    }
    $pdf->SetTitle($__pdf_title);
    $pdf->SetAuthor($__pdf_author);
    $pdf->SetCreator($__pdf_creator);
    $pdf->SetSubject($__pdf_subject);
    $pdf->SetKeywords($__pdf_keywords);
    if ($__pdf_wm_text != "") {
        $pdf->SetWatermarkText($__pdf_wm_text, $__pdf_wm_talpha);
        $pdf->showWatermarkText = true;
        if ($__pdf_wm_font) {
            $pdf->watermark_font = $__pdf_wm_font;
        }
    }
    if (file_exists($__pdf_wm_img)) {
        $pdf->SetWatermarkImage($__pdf_wm_img, $__pdf_wm_ialpha);
        $pdf->showWatermarkImage = true;
    }
    $pdf->WriteHTML($__pdf_html);
    $pdf->Output($filename, $dest);
}