Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 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, $back_color, $fore_color, $cmyk);
return $enc->encodeEPS($text, $outfile, $saveandprint=false);
}

//----------------------------------------------------------------------
public static function latex_rules($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $writeheader=true, $back_color = 0xFFFFFF, $fore_color = 0x000000, $cmyk = false)
{
$enc = QRencode::factory($level, $size, $margin, $back_color, $fore_color, $cmyk);
return $enc->encodeLatex_Rules($text, $outfile, $size, $writeheader);
}

//----------------------------------------------------------------------
public static function svg($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false, $back_color = 0xFFFFFF, $fore_color = 0x000000)
Expand Down Expand Up @@ -543,6 +550,28 @@ public function encodeEPS($intext, $outfile = false,$saveandprint=false)
}
}

//----------------------------------------------------------------------
public function encodeLatex_Rules($intext, $outfile = false, $totalsize = "16", $writeheader = true)
{
try {

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

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

return QRvect::latex_rules($tab, $outfile, sprintf("%.3fmm", $totalsize / strlen($tab[0])), $writeheader);

} catch (Exception $e) {

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

}
}

//----------------------------------------------------------------------
public function encodeSVG($intext, $outfile = false,$saveandprint=false)
{
Expand Down
51 changes: 49 additions & 2 deletions qrvect.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

class QRvect {

//----------------------------------------------------------------------
public static function eps($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE, $back_color = 0xFFFFFF, $fore_color = 0x000000, $cmyk = false)
{
$vect = self::vectEPS($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color, $cmyk);
Expand All @@ -46,7 +45,7 @@ public static function eps($frame, $filename = false, $pixelPerPoint = 4, $outer
}
}
}


//----------------------------------------------------------------------
private static function vectEPS($frame, $pixelPerPoint = 4, $outerFrame = 4, $back_color = 0xFFFFFF, $fore_color = 0x000000, $cmyk = false)
Expand Down Expand Up @@ -135,6 +134,54 @@ private static function vectEPS($frame, $pixelPerPoint = 4, $outerFrame = 4, $ba

return $output;
}

//----------------------------------------------------------------------
public static function latex_rules($frame, $filename = false, $blocksize = "2mm", $writeheader = true)
{
$output = "";
if($writeheader)
{
$output .= "\\documentclass{article}\n";
$output .= "\\begin{document}\n";
$output .= "\\newlength\\qrmodulesize\n";
$output .= "\\newlength\qrminipagewidth\n";
}

$h = count($frame);
$w = strlen($frame[0]);

$output .= "\\setlength{\\qrmodulesize}{" . $blocksize . "}\n";
$output .= "\\setlength{\\qrminipagewidth}{\\qrmodulesize}\n";
$output .= "\\multiply\\qrminipagewidth by $w\n";

$output .= "\\begin{minipage}{\\qrminipagewidth}\n";
$output .= "\\baselineskip=\\qrmodulesize\n";
$output .= "\\parindent=0mm\n";
$output .= "\\def\\qrb{\\rule{\\qrmodulesize}{\\qrmodulesize}}\n";
$output .= "\\def\\qrw{\\rule{\\qrmodulesize}{0pt}}\n";

for($i=0; $i<$h; $i++) {
$output .= "\\par";
for($j=0; $j<$w; $j++) {
if( $frame[$i][$j] == '1')
$output .= "\\qrb";
else
$output .= "\\qrw";
}
}

$output .= "\\end{minipage}\n";

if($writeheader)
$output .= "\\end{document}\n";

if($filename)
QRtools::save($output, $filename);
else
return($output);
}



//----------------------------------------------------------------------
public static function svg($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE, $back_color, $fore_color)
Expand Down