Skip to content

Instantly share code, notes, and snippets.

@baileylo
Forked from manoot/gist:1711158
Created January 31, 2012 16:35
Show Gist options
  • Save baileylo/1711470 to your computer and use it in GitHub Desktop.
Save baileylo/1711470 to your computer and use it in GitHub Desktop.
<?php
$prev_line = false;
foreach ($data as $line){
// go through each line, showing it as required, if it is surrounded by '<>' then
// assume that it is a title
$prev_line = $line=chop($line);
if (strlen($line) && $line[0]=='#'){
// comment, or new page request
switch($line){
case '#NP':
$pdf->ezNewPage();
break;
case '#C':
$pdf->selectFont($codeFont);
$textOptions = array('justification'=>'left','left'=>20,'right'=>20);
$size=10;
break;
case '#c':
$pdf->selectFont($mainFont);
$textOptions = array('justification'=>'full');
$size=12;
break;
case '#X':
$collecting=1;
break;
case '#x':
$pdf->saveState();
eval($code);
$pdf->restoreState();
$pdf->selectFont($mainFont);
$code='';
$collecting=0;
break;
case '#I':
$collecting=1;
break;
case '#i':
$pdf->addPngFromFile($prev_line);
$collecting=0;
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment