update header from docx format

This commit is contained in:
iIronside 2022-11-14 15:11:46 +03:00
parent 9523ed7475
commit 0f8aa34b4f
2 changed files with 13 additions and 10 deletions

View File

@ -312,21 +312,24 @@ class UserCardController extends Controller
$model = UserCard::findOne($id);
$resumeTemplate = ResumeTemplate::findOne($model->resume_template_id);
$imagePath = Yii::getAlias('@frontend') . '/web' . $resumeTemplate->header_image;
if (empty($resumeTemplate->header_text)) {
$headerText = 'Generated by ITGuild.info At: ' . date("d/m/Y");
} else {
$headerText = $resumeTemplate->header_text;
}
$pw = new \PhpOffice\PhpWord\PhpWord();
// $header = $section->createHeader();
// $header->addImage('/home/dev238/projects/aegis/images/Logo_.jpg',['align'=>'right']);
// (B) ADD HTML CONTENT
$section = $pw->addSection();
$header = $section->addHeader();
if (pathinfo($resumeTemplate->header_image, PATHINFO_EXTENSION)) {
$header->addImage($imagePath, ['width' => 70, 'height' => 30, 'align' => 'left']);
}
$header->addText($headerText, array('bold' => false), array('space' => array('before' => 0, 'after' => 280)));
// $section->addImage( Yii::getAlias('@frontend') . '/media/upload/guild.png', ['width' => '200', 'height' => '200', 'align' => 'center',]);
// $header = $section->addHeader();
// $header->addImage('frontend/web/media/upload/guild.png', ['align' => 'left']);
$resumeText = str_replace(array('<br/>', '<br>', '</br>'), ' ', $model->resume_text);
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $resumeText, false, false);

View File

@ -36,7 +36,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'header_text')->textInput(['maxlength' => true]) ?>
<div class="imgUpload form-group">
<div class="media__upload_img" style="width: 0">
<div class="media__upload_img">
<img src="<?= $model->header_image; ?>" width="100px"/>
</div>
<?php echo InputFile::widget([