Я использую Laravel 4 с пакетом dompdf: https://github.com/barryvdh/laravel-dompdf а>
Когда я создаю отчет и он преобразует его в PDF на моем локальном компьютере, все в порядке и отображается хорошо, но когда я делаю то же самое на своем рабочем сервере, он отображает случайные буквы там, где есть либо динамический, либо статический контент.
Скриншот местного производства по сравнению с производством:
http://s28.postimg.org/u5zk3pc19/report_diff.png
Вот код, который создает PDF:
/**
* Create PDF
*
*/
public function createPdf( $reportData )
{
if( $this->validate() )
{
// Get Final Data Information
$btu_hp = static::getBtuHp( $reportData['booth_cfm'], $reportData['cure_temp_hp'], $reportData['outside_temp'] );
$btu_current = static::getBtuCurrent( $reportData['booth_cfm'], $reportData['bake_temp_current'], $reportData['outside_temp'] );
$reportData['energy_percentage_per_unit'] = static::getEnergyPercentagePerUnit( $btu_hp, $btu_current );
$reportData['energy_dollar_per_unit'] = static::getEnergyDollarPerUnit( $reportData['cost_per_therm'], $reportData['bake_time_current'], $reportData['cure_time_hp'], $btu_current, $btu_hp );
$reportData['time_savings_per_unit'] = static::getTimeSavingsPerUnit( $reportData['bake_time_current'], $reportData['cure_time_hp'] );
$reportData['time_savings_per_year'] = static::getTimeSavingsPerYear( $reportData['time_savings_per_unit'][0], $reportData['units_per_day'], $reportData['production_days'] );
$reportData['labor_dollar_per_year'] = static::getLaborDollarPerYear( $reportData['labor_rate'], $reportData['time_savings_per_year'][0] );
$reportData['energy_dollar_per_year'] = static::getEnergyDollarPerYear( $reportData['energy_dollar_per_unit'][0], $reportData['units_per_day'], $reportData['production_days'] );
$view = View::make('pages.report.hp-report.print', array('report' => $reportData));
if( ! $this->saveAsPdf($view, $this->generateFileName()) )
{
return false;
}
return true;
}
return false;
}
/**
* Save report as PDF
* @param html HTML of PDF
* @param fileName Name of File
*
*/
public function saveAsPdf( $html, $fileName = null )
{
if(is_null($fileName))
$fileName = $this->generateFileName();
$htmlPath = $this->reportDirectory.'/'.$fileName.'.html';
$pdfPath = $this->reportDirectory.'/'.$fileName.'.pdf';
file_put_contents( $htmlPath, $html );
// set recent PDF to name of PDF
$this->recentReportFile = $fileName . '.pdf';
return PDF::loadFile($htmlPath)->save($pdfPath);
}
/**
* Get most recent uploaded PDF
*
*/
public function getRecentPdf()
{
return $this->recentReportFile;
}
/**
* Generate file name for PDF
*
*/
public function generateFileName()
{
return Auth::user()->id . '_hp_' . str_random(10) . '_' . time();
}
Все пишет нормально, использует правильный шаблон и имеет стиль... Только статическое содержимое и динамическое содержимое (значения, записанные с помощью переменных PHP) отображаются плохо, хотя вы можете видеть некоторое статическое содержимое вроде Энергосбережение и такие печатает нормально.
Есть ли причина, по которой все это может быть перемешано на рабочем сервере, а не локально?
Вот HTML для захватываемого представления (HTML, в который вводятся переменные php): http://pastebin.com/5bMR6G2s
А вот мой файл конфигурации для dompdf: http://pastebin.com/Ld6MQckG