-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Describe the bug and add attachments
<p style="line-height: 4;">this is my first line</p><p style="line-height: 4;">here is the second line</p><p style="line-height: 4;">here is the third line</p><ul><li style="line-height: 4;">first list</li><li style="line-height: 4;">second list </li><li style="line-height: 4;">third list</li></ul>
The line height working on p tag but not working on lists(ul, ol) it works only when i set as default using package classes
$phpWord->setDefaultParagraphStyle(
array(
//'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::LEFT,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(0),
'lineHeight' => 1.30,
)
);
but it effect on the complete page, I want to implement that written in style for each element. in some elements may be 3, 4 or different.
Expected behavior
i want to implement line hight using inline style on lists in html like it is working fine for other tags but not on lists.
<ul><li style="line-height: 4;">first list</li><li style="line-height: 4;">second list </li><li style="line-height: 4;">third list</li></ul>
Steps to reproduce
private function data_for_word($request, $jobs, $relation, $type, $version = null)
{
//create folder
$foldername = 'user_export_' . Auth::guard('users')->user()->id;
$path = storage_path($foldername);
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
if (isset($request->file_type) && !empty($request->file_type)) {
$type = $request->file_type;
}
$jobTitleStyle = new \PhpOffice\PhpWord\Style\Font();
$jobTitleStyle->setBold(true);
$jobTitleStyle->setSize(24);
$user = Auth::user();
if($user->roles) {
$user['role'] = $user->roles[0]->id;
$user['user_role'] = $user->roles[0]->name;
$role = Role::findById($user['role'], 'users');
}
$permissions = $role->permissions->pluck('name')->toArray();
foreach ($jobs as $job) {
if ($job->Template->template_logo != Null && file_exists(public_path('images/logos/' . $job->Template->template_logo))) {
$template_logo = public_path('images/logos/' . $job->Template->template_logo);
} else {
$template_logo = public_path('images/mosh-logo.png');
}
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Set default document styles
$phpWord->setDefaultFontName('Arial');
$phpWord->setDefaultFontSize(12);
$section = $phpWord->addSection([
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(0.5),
'marginRight' => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(0.5),
]);
// Add a section to the document
// $section = $phpWord->addSection();
if ($job->status == 'draft') {
// Define the watermark image path
$watermarkImagePath = public_path('/watermarks/' . $job->status . '-red.jpg'); // Replace with the actual path to your watermark image
$header = $section->createHeader();
$header->addWatermark($watermarkImagePath, array('positioning' => 'relative', 'marginTop' => 0, 'marginLeft' => 0));
}
$title = $job->job_title;
$columns = $request->columns_to_includes;
if(!isset($request->export_fields)){
$jd_fields = $request->jd_fields ? $request->jd_fields : [];
}
if(isset($request->export_fields) && $request->export_fields){
if (in_array('view_hidden_attribute', $permissions)) {
$jd_fields = ClientsJobDescriptions::where('job_id',$job->id)->where('section','header')->orderBy('position', 'asc')->get();
} else {
$jd_fields = ClientsJobDescriptions::where('job_id',$job->id)->where('section','header')->orderBy('position', 'asc')->where('hidden',0)->get();
}
foreach ($jd_fields as $field) {
$field->exportable = true;
}
}
if($relation == 'ClientJobDescriptionVersion'){
if (in_array('view_hidden_attribute', $permissions)) {
$jd_fields = ClientsJobDescriptionsVersion::where('job_id',$job->id)->where('section','header')->where('version',$version)->get();
} else {
$jd_fields = ClientsJobDescriptionsVersion::where('job_id',$job->id)->where('section','header')->where('hidden',0)->where('version',$version)->get();
}
foreach ($jd_fields as $field) {
$field->exportable = true;
}
}
$sections = isset($request->section) ? false : true;
$html = '<table style="width: 100%; border: 0px; font-family: Arial, sans-serif; margin-bottom:40px;">
<tr>
<td style="text-align:left; width: 75%;font-size:20px; color:#404040; vertical-align:middle; text-transform: capatilize;font-weight: bold;">' . htmlspecialchars($title) . '</td>
<td style="width:25%"><img src="' . $template_logo . '" width="100" style="float:right;"/></td>
</tr>
</table>';
$html .= '<p style="margin-top:5pt;"></p>';
$show = $sections && !in_array('gray', $columns) ? false : true;
$html .= '<p style="margin-bottom:10pt;"></p>';
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
foreach ($job->{$relation} as $job_info) {
$show = $sections && !in_array($job_info->id, $columns) ? false : true;
if ($show) {
if ($job_info->section == 'section') {
$html = '<br></br><h4 style="font-size:15px; font-family: Arial, sans-serif, Helvetica Neue, Roboto, Noto Sans, sans-serif;; color: #404040; font-weight: bold;">' . htmlspecialchars(strip_tags(strtoupper($job_info->column_name ?? $job_info->ColumnDetail->column_name))) . '</h4><br></br>';
$modified_html = Helper::sanitize_from_word('' . str_replace('<br>', '<br/>', $job_info->value) . '');
$html .= \App\Helpers\Helper::replace_html_tags_word($modified_html);
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
}
}
}
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
try {
$objWriter->save(storage_path($foldername . '/' . Helper::fileName($job) . '.docx'));
} catch (Exception $e) {
}
}
if ($type == 'zip') {
$zip = new ZipArchive;
$zipfilename = 'bulk_job_export' . Auth::guard('users')->user()->id . '.zip';
if ($zip->open(storage_path($zipfilename), ZipArchive::CREATE) === TRUE) {
$files = File::files($path);
foreach ($files as $key => $value) {
$relativeNameInZipFile = basename($value);
$zip->addFile($value, $relativeNameInZipFile);
}
$zip->close();
}
File::deleteDirectory($path);
return storage_path($zipfilename);
return response()->download(storage_path($zipfilename))->deleteFileAfterSend(true);
} else {
return storage_path($foldername . '/' . Helper::fileName($job) . '.docx');
return response()->download(storage_path($foldername . '/job-' . $job->id . '.docx'))->deleteFileAfterSend(true);
}
}
PHPWord version(s) where the bug happened
0.18.3 and 1.3
PHP version(s) where the bug happened
7.4
Priority
- I want to crowdfund the bug fix (with @algora-io) and fund a community developer.I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Activity