How use alternative font with writeHTMLCell - pdf

I am using TCPDF library and I would like to use a different font after setting "setFont".
PS: in the following example Titillium font has already been converted to tcpdf.
This is my code:
$pdf->SetTextColor(0,0,0);
$pdf->setFont('Arial','',10);
$html = <<<EOD
<div style="font-family:'Titillium Web';">Hello!</div>
EOD;
$pdf->writeHTMLCell('', '', 10, 10, $html, '', 0, '', true, '', true);
This still contains the Arial font inside.
I also tried :
$pdf->SetTextColor(0,0,0);
$pdf->setFont('Arial','',10);
$html = <<<EOD
<style>
.usefont{ font-family:'Titillium Web'; }
</style>
<div class="usefont">Hello!</div>
EOD;
$pdf->writeHTMLCell('', '', 10, 10, $html, '', 0, '', true, '', true);
but nothing.
Any idea?

Related

error Arabic sentence for words are reversed on datatables pdfhtml5 with laravel8

this example for errorenter image description here 'customize' =>"function(doc) {
margin: [ 0, 0, 0, 5 ],
} );
}",
You can solve it by using this code example
text:'الخير صباح'.split(' ').reverse().join(' '),

Changing color of x-axis label in bar chart

I'm using react-native-charts-wrapper for creating a chart and I was wondering if there is a way to change the x-axis label style for just one bar? I have a whole week in the chart and I want to change the color of the current day. So if today is Monday I just want the M to be a different color. I don't want to change the color of the bar, just the letter under it.
These are settings for xAxis:
xAxis: {
drawAxisLine: true,
drawGridLines: false,
position: 'BOTTOM',
labelCount: 7,
valueFormatter: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
textColor: formatedColor,
axisMinimum: -1,
axisMaximum: 7,
avoidFirstLastClipping: true,
},
I checked the documentation and properties but couldn't find anything.
I think I know
core:google.charts.load('current');
ChartType: ColumnChart;
Don't use the bar
google.charts.load('current');
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
dataTable: [
['Element', 'Density', { role: 'style' }],
['Copper', 8.94, '#b87333'],
['Silver', 10.49, 'silver'],
['Gold', 19.30, 'gold'],
['Platinum', 21.45, 'color: #e5e4e2' ],
],
options: {'title': 'Countries'},
containerId: 'columnchart_values'
});
wrapper.draw();
}

PDF library tcpdf in landscape orientation and pdf->SetXY doesn't work as expected?

I can not figure this one out how tcpdf recalculates x and y coordinates if orientation is landscape. The only way i can get a bit of control is to put text in a writeHTML
// QR code
$style = array(
'border' => false,
'padding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false
);
$pdf->SetXY(0, 0);
$pdf->write2DBarcode('http://www.google.com/', 'QRCODE,H', 0, 1, 40, 40, $style, 'N');
// set text content
$pdf->SetXY(2, 37);
//$pdf->SetXY(30, 7);
$pdf->SetFontSize(10);
$textData = '<p>Matthew Pitt</p>'
. '<p>Google Light Company</p>';
$pdf->writeHTML($textData, true, false, false, false, 'R');
and the result is
Ideally I like to layout the text on the right of the QR code. Multiline if a name is very long and text-align left?? Any tips, suggestions?
For those in the same situation in my case $pdf->MultiCell did the job as I don't know how many characters a name will have. And using a table cell would not let me display a name on multiline
$style = array(
'border' => false,
'padding' => 'auto',
'fgcolor' => array(0, 0, 0),
'bgcolor' => false
);
$pdf->SetXY(0, 0);
$pdf->write2DBarcode('http://www.google.com/', 'QRCODE,H', 0, 1, 40, 40, $style, 'N');
// set text content
$pdf->SetXY(42, 7);
$pdf->SetFontSize(10);
//
$textData = '<p>Matthew Pitt</p>'
. '<p>Google Light Company</p>';
//$pdf->writeHTML($textData, true, false, false, false, 'L');
$pdf->SetXY(40, 7);
$htmlHead = '<table width="250" border="0">
<tr>
<td align="left">Matthew Pitt Matthew Pitt Matthew Pitt</td>
</tr>
<tr>
<td align="left">Good Light Company</td>
</tr>
</table>';
//$pdf->writeHTML($htmlHead, true, false, true, false, '');//<- check this didn't work 100% correctly
$txt = 'Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt';
$pdf->MultiCell(45, 5, $txt, 0, '', 0, 1, '', '', true);
$pdf->Ln(1);
$pdf->SetX(40);
$txt2 = 'Google Company Light';
$pdf->MultiCell(45, 5, $txt2, 0, '', 0, 1, '', '', true);

javascript variable assign in function

i have a problem with a variable that i'm trying to assign, here is my partial code:
function calendar2(result1){
//alert(result1);
var calendar = $('#event_calendar');
calendar.empty();
calendar.fullCalendar({
header: {
left: 'title',
right: 'month,agendaWeek,agendaDay today prev,next'
},
//defaultView: 'basicWeek',
editable: false,
firstDay: 0,
height: 600,
droppable: false,
events: result1,
...
if i uncomment 'alert(result1);' the result is shown but the text from result1 is not assign to events. How can i assign it?
Waiting for a solution, thanks.

Dojo charting: How do you return an error if the chart is empty?

I'm pulling information from a database and putting it into a dojo chart. I'm trying to figure out how to return a 'no data message' with the way this chart is working:
var chart1 = new dojox.charting.Chart2D("traffic");
chart1.addPlot("default", {type: "Columns", gap: "15"});
chart1.addAxis("x", {minorTicks: false, font: "normal normal bold 9pt Arial",
labels: [{value: 1, text: 'Monday'},{value: 2, text: 'Tuesday'},{value: 3, text: 'Wednesday'},{value: 4, text: 'Thursday'},{value: 5, text: 'Friday'},{value: 6, text: 'Saturday'},{value: 7, text: 'Sunday'}]});
chart1.addAxis("y", {vertical: true, minorTicks: false, min: 0, font: "normal normal bold 12pt Arial"});
chart1.addSeries("Series 1", [<?php echo $trafficseries; ?>]);
chart1.setTheme(dojox.charting.themes.PlotKit.blue);
chart1.addPlot("Grid", {
type: "Grid",
hAxis: "x",
vAxis: "y",
hMajorLines: true,
hMinorLines: false,
vMajorLines: false,
vMinorLines: false
});
var anim_t = new dojox.charting.action2d.Tooltip(chart1, "default");
chart1.render();
Where would I add some sort of error handling if the data was empty?
Check, if your data has no points, and overlay a <div> over a chart with "no data" message. Otherwise hide it.