Код: Выделить всё
- Ingredienti :
- 2 Melanzane (circa 1 kg)
- 3 spicchi d'aglio
- 30 ml di succo di limone
не переводится на новую строку. Вот код, который я использую:
Код: Выделить всё
use PhpOffice\PhpWord\TemplateProcessor;
....
function fillTemplate($templatePath, $outputPath, $context) {
try {
// Load the template
$templateProcessor = new TemplateProcessor($templatePath);
PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
// Replace placeholders with provided content
foreach ($context as $placeholder => $content) {
// Replace the placeholder
$templateProcessor->setValue($placeholder, $content);
}
// Save the generated document
$templateProcessor->saveAs($outputPath);
// Output debug information
echo "Template processed successfully. Output saved to: $outputPath\n";
} catch (Exception $e) {
// Handle errors
echo "Error processing template: " . $e->getMessage() . "\n";
}
}
В полученном выходном файле docx отображается «
» вместо создания новой строки в документе Word. .
Подробнее здесь: https://stackoverflow.com/questions/780 ... eprocessor
Мобильная версия