How to use bold font in DOMPDF? - dompdf

I am using Verdana for DOMPDF.
I have added below code:
'verdana' =>
array(
'bold' => DOMPDF_DIR . '/lib/fonts/Verdana_Bold',
'bold_italic' => DOMPDF_DIR . '/lib/fonts/Verdana_Bold_Italic',
'italic' => DOMPDF_DIR . '/lib/fonts/Verdana_Italic',
'normal' => DOMPDF_DIR . '/lib/fonts/Verdana',
),
Verdana is working fine. I want to use bold for this.
font-weight: bold; not working
Any help?
Thanks

Related

Add malayalam font in mPDF in Laravel application

I am using mPDF in my Laravel application. My pdf file comes with both English and Malayalam languages. But Malayalam content not loading properly. I tried to add new font, but it's always showing missing OTL table error. Here is my code.
config/pdf.php
return [
'mode' => 'utf-8',
'format' => 'A4',
'author' => '',
'subject' => '',
'keywords' => '',
'creator' => 'Laravel Pdf',
'display_mode' => 'fullpage',
//'tempDir' => base_path('../temp/'),
'tempDir' => __DIR__.'/../temp/',
//'tempDir' => __DIR__.'/../storage/framework/pdf/',
'pdf_a' => false,
'pdf_a_auto' => false,
'icc_profile_path' => '',
'font_path' => base_path('resources/fonts/'),
'font_data' => [
'malayalam' => [
'R' => 'ECBThinkal.ttf', // regular font
'B' => 'ECBThinkal.ttf', // optional: bold font
'I' => 'ECBThinkal.ttf', // optional: italic font
'BI' => 'ECBThinkal.ttf', // optional: bold-italic font
'useOTL' => 0xFF,
'useKashida' => 75,
]
]
];
view.blade.php
<html>
<?php header('Content-Type: text/html; charset=utf-8');?>
<head>
<style>
body {
font-family: 'malayalam', sans-serif;
}
</style>
I am not pasting full code. When I try to create pdf it returns error Unable to set font "D:\xampp\htdocs\xxxxx\resources/fonts//ECBThinkal.ttf" to use OTL as it does not include OTL tables (or at least not a GDEF table).
Tried some other fonts also, but still this error is showing.
I guess this is what you are missing in your config.
'autoLangToFont' => true,
Reference: https://mpdf.github.io/fonts-languages/automatic-font-selection.html

Insertion code does not work in 1.7 which was working in 1.6

I have a Prestashop 1.6 module which has in one point prepares a PDF with barcodes.
The same module I upgraded to 1.7 but now PDF generates without the barcode. I did not change any thing in the template nor controller but bar code does not appear.
I followed this link to prepare bar codes for 1.6 version.
Following is my controller code where bar code prepared.
// Initiat PDF class
$pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE'));
// Prepare barcode
$barcode_params = $pdf->serializeTCPDFtagParameters(array(
'123456789',
'C39',
'',
'',
50,
20,
0.2,
array(
'position'=>'S',
'border'=>false,
'padding'=>0,
'fgcolor'=>array(0,0,0),
'bgcolor'=>array(255,255,255),
'text'=>true,
'font'=>'Helvetica',
'fontsize'=>8,
'stretchtext'=>0),
'N'));
Following is template code,
<tr>
<td>
<b>Shipper Order Number:</b>
</td>
<td >
<tcpdf method="write1DBarcode" params="{$barcode_params}"/>
</td>
</tr>
Any advice would be greatly appreciated..
Ok, I resolved this issue myself.
But not with this method. for some reason
<tcpd method="write1DBarcode" ... '
seems does not work.
So what I did was I bypassed 'HTMLTemplate..'  class creation and smarty templates all together  for labels and instead used a normal method to output a PDF custom HTML label using native function of TCPD class. 
so here is the codes I used for producing the PDF label.
$style = array(
'position' => 'C',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => true,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => array(255,255,255),
'text' => true,
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
$html = '<html><head><title></title><style>table { border-collapse:
collapse;font-family:arial;}td {padding: 10px; vertical-align: center;}';
$html .= '</style></head><body>';
foreach ($orders_array as $order)
{
$html = $this->prepare_html_label($order); //  this is where my html
template is prepared with actual values
$pdf->setXY(93,472);
$pdf->Ln(5);
$pdf->write1DBarcode('*'.$order['awb'].'*', 'C128', '', '', '', 18, 0.4,
$style, 'N');
$pdf->Ln(10);
$pdf->writeHTML($html, true, false, true, false, '');
}
$pdf->Output('labels.pdf', 'D');
}
Problem solved.! 
Hope this helps some one.

Add image to button Laravel 5

Hi my submit button is like this:
{!! Form::open([
'id' => 'form-id',
'method' => 'delete',
'action' => ['ToDoListController#delete', $task->id],
]) !!}
{!! Form::submit('Delete', [
'id' => 'my-id',
'name' => 'bt_add',
'image' => '../../images/delete.jpg',
]) !!}
{!! Form::close() !!}
I want to add image to my button but don't know how. Please help me.
Why not use a button?
<button type="submit" id="my-id" name="btn_add"><img src=""></button>
You can add a css class to your button and then define the image to be used in that class e.g.
{!! Form::submit('Delete', [
'id' => 'my-id',
'name' => 'bt_add',
'class' => 'bt_add',
]) !!}
In the css...
.bt_add {
background:url(/images/Btn.PNG) no-repeat;
width: 200px;
height: 100px;
border: none;
}
Sorry I haven't tested this (bit of a hurry) but this should give you the effect you want. See other posts on button images e.g. Setting an image button in CSS - image:active

Creating image link creates a path adding controller name

I am trying to implement a image gallery in cakephp with below structure:
echo $this->Html->link(
$this->Html->image('gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
array('class'=>'img img-responsive')
),
'gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
array(
'class' => 'col-sm-4',
'escape' => false,
'data-toggle' => 'lightbox',
'data-gallery' => 'multiimages',
)
);
But the above script outputs HTML:
<a href="/nitish/cakem/galleries/gallery/fashion/fashion-photography-guwahati-big-4.jpg" class="col-sm-4" data-toggle="lightbox" data-gallery="multiimages">
<img src="/nitish/cakem/img/gallery/fashion/fashion-photography-guwahati-4.jpg" class="img img-responsive" alt="" />
</a>
As you can see in the anchor path, additional galleries directory is added. How to remove this ?
NB: galleries is my controller name
Strart you paths with a slash:
echo $this->Html->link(
$this->Html->image('/gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
array('class'=>'img img-responsive')
),
'/gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
array(
'class' => 'col-sm-4',
'escape' => false,
'data-toggle' => 'lightbox',
'data-gallery' => 'multiimages',
)
);

Magento grid column change align to center in number type

When you are using the number type in Magento's grid column:
$this->addColumn('my_number',
array(
'header' =>Mage::helper('bidashboard')->__('My number'),
'index' => 'my_number',
'total' => 'sum',
'align' => 'center',
'type' => 'number',
'sortable' => false,
));
It seems the 'align' has no affect on it. It is because the align hard-coded on the number type renderer:
class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Number
...
public function renderCss()
{
return parent::renderCss() . ' a-right';
}
...
So how do I change the align in this case?
The a-right class in the default Magento 1.7.0.2 css file:
/skin/frontend/default/default/css/styles.css
in line 77 has
.a-right {
text-align: left !important;
}
so I guess overwriting this css class in your theme's css file will fix this.
Like this:
body.checkout-cart-index .a-right {
text-align: left !important;
}
or this:
body.checkout-cart-index #shopping-cart-table td:nth-child(7) {
text-align: left !important;
}

Resources