Skip to content

Commit

Permalink
Added rendertofile, and explicit path addition
Browse files Browse the repository at this point in the history
  • Loading branch information
guyc committed May 16, 2013
1 parent 5e5280b commit 346f8e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Foml.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ static function XslFoToPdf($XslFo)

$cmd = "{$fop} {$escapedXslFoFileName} {$escapedPdfFileName} -c {$escapedConfFileName}";
$env = $_ENV;

// It seems that something changed (at FreeBSD 9.1?) that means that apache no longer
// has /usr/local/bin in the path by default. We add it here for fop because that is where
// Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)
// is installed.
$env['PATH'].= ':/usr/local/bin';

// Fop tries to create a font cache at [user.home]/.fop/fop-fonts.cache
// see: https://github.com/apache/fop/blob/trunk/src/java/org/apache/fop/fonts/FontCache.java
// Because the apache-user doesn't have a home directory, this causes a fatal error unless we
Expand Down Expand Up @@ -154,10 +161,16 @@ static function XslFoToPdf($XslFo)
return $pdfFileName;
}

static function Render($Template, $Args=null, $Headers=null)
static function RenderToFile($Template, $Args)
{
$xslFo = Foml::GenerateXslFo($Template, $Args);
$pdfFileName = Foml::XslFoToPdf($xslFo);
return $pdfFileName;
}

static function Render($Template, $Args=null, $Headers=null)
{
$pdfFileName = self::RenderToFile($Template, $Args);
$size = filesize($pdfFileName);
$pdfMimeType = Foml::$pdfMimeType;

Expand Down
1 change: 1 addition & 0 deletions fop.xconf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ the location of this file.

<fonts>
<directory>/data/www/FOML/fonts</directory>
<!-- auto-detect will add the system default font paths to the font search path -->
<!--
<directory>fonts</directory>
<auto-detect/>
Expand Down

0 comments on commit 346f8e7

Please sign in to comment.