Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
adding svg export support and file writing support
Browse files Browse the repository at this point in the history
  • Loading branch information
t0k4rt committed Feb 9, 2012
1 parent 57ef45a commit 7632c7e
Show file tree
Hide file tree
Showing 3 changed files with 292 additions and 177 deletions.
31 changes: 31 additions & 0 deletions qrencode.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ public static function eps($text, $outfile = false, $level = QR_ECLEVEL_L, $size
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodeEPS($text, $outfile, $saveandprint=false);
}

//----------------------------------------------------------------------
public static function svg($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodeSVG($text, $outfile, $saveandprint=false);
}

//----------------------------------------------------------------------
public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
Expand Down Expand Up @@ -530,4 +537,28 @@ public function encodeEPS($intext, $outfile = false,$saveandprint=false)

}
}

//----------------------------------------------------------------------
public function encodeSVG($intext, $outfile = false,$saveandprint=false)
{
try {

ob_start();
$tab = $this->encode($intext);
$err = ob_get_contents();
ob_end_clean();

if ($err != '')
QRtools::log($outfile, $err);

$maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));

return QRvect::svg($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);

} catch (Exception $e) {

QRtools::log($outfile, $e->getMessage());

}
}
}
Loading

0 comments on commit 7632c7e

Please sign in to comment.