TCPDF fill_color = array() does not accept variable? - tcpdf

$myBgColor = '255, 255, 255';
$this->Rect(0, 0, 210, 310, 'F', array(), array($myBgColor));
Why does not it? Direct input works fine.

I have solved this way:
$myBgColor = $this->hex2rgb('#ffffff');
see the function here:
hex2rgb
$this->Rect(0, 0, 210, 310, 'F', array(), $myBgColor);
works perfectly!

Related

How can I make the images position to the top and doc.text no worked

how to let image and the 'Hello World' text show at the top, the table but the doc.text doesn't work in the pdf.
const doc = new jspdf();
var imgData2 = 'data:image/jpeg;base64,/verylongtextcode';
doc.addImage(imgData2, "PNG", 10, 78, 150, 50);
doc.text("Hello World", 15, 20);
doc.autoTable({ html: "#mytable" });
doc.save("table.pdf");

Roblox Lua - Color3 expected, got string

local colorTable = {
('11, 13, 48'),
('35, 48, 48'),
('6, 47, 6'),
('91, 5, 7')
}
local value = math.random(1,#colorTable)
local picked_value = colorTable[value]
script.Parent.Background.BackgroundColor3 = picked_value
My error code was Color3 expected, got string, is there anything I can fix this? My goal was simple, randomizing a specific color rgb to a frame backrgound.
A Color3 object can be created by Color3.fromRGB.
local colorTable = {
Color3.fromRGB(11, 13, 48),
...
}

JSPDF Autotable not exporting defined table footer

I have an html table defined based on dynamic data. The table contains a thead, tfoot and tbody. The tfoot is mapped to specific values within my json. However, when using JSPDF Autotable and exporting to PDF the footer is not rendered. I have seen information but no code examples of the showfoot option and have tried it after the doc.autotable, and even after the style options but to no avail. The footer is not exported. I'm sure it super simple - but I can't seem to figure it out. Note: I do not want JSDPF Autotable to 'create' a footer - it is defined, it is part of my table - I simply want it rendered on the pdf. I found an old stackoverflow from 2016 where this was mentioned - Simon B. commented it would be added - the topic was closed - but I couldn't find a code example anywhere.
Here is my jspdf autotable code where I have tried to 'show my footer' - but to no avail. Any assistance appreciated.
<script>
function generate() {
//Creation of PDF document
let doc = new jsPDF('l', 'pt');
const totalPagesExp = '{total_pages_count_string}';
var elem = document.getElementById('${pm.info.requestId}');
var data = doc.autoTableHtmlToJson(elem);
doc.autoTable(data.columns, data.rows, {
headStyles: {
cellWidth: 'wrap',
fontSize: 10,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [255,255,255]
},
bodyStyles: {
cellWidth: 'wrap',
fontSize: 8,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [255,255,255]
},
footStyles: {
cellWidth: 'wrap',
fontSize: 10,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [211,211,211]
},
//Formatting of pages
didDrawPage: function (data) {
//Summa logo on top of the page
doc.addImage('${pm.variables.get("summa")}', 'PNG', 20, 20, 145, 42.63);
//Font sizes of report information
doc.setFontSize(8);
//Report information: portfolio name, knowledge time and report time
doc.text(35, 75, '${pm.variables.get("portfolioName")}');
doc.text(35, 85, '${pm.variables.get("reportTime")}');
doc.text(35, 95, '${pm.variables.get("knowledgeTime")}');
//Page numbers
var str = "Page " + doc.internal.getNumberOfPages()
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp;
};
//Page size
var pageSize = doc.internal.pageSize;
var pageHeight = pageSize.height ? pageSize.height : pageSize.getHeight();
doc.text('Theme "plain"', 14, 16);
},
margin: {
top: 100
},
});
//Number of pages
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
},
//--------------------------------------------------------------------------------------------------START
//Change name of report if desired
doc.save('${pm.info.requestName}${pm.variables.get("reportTime")}.pdf');
//--------------------------------------------------------------------------------------------------END
}
Not sure if you already managed to export footer totals to the jspdf. I got it to working, with a small adjustment.
Replace the var elem = document.getElementById('${pm.info.requestId}'); to var elem = document.getElementById('NAME');
And replace the doc.autoTable(data.columns, data.rows, { to doc.autoTable({html: '#NAME',

Getting trouble in the jsPdf auto-table Custom width Columns

Hi all Am trying to Increase my Specified column size Column size , So i used like this {columnStyles: {xxx: {columnWidth: 18}}} , Column size was increased but next lines's are getting affected . That mean's next line is theme: 'grid', mean's it's not working . Can someone clarify me pls . Here is My code ,
doc.autoTable(getColumns(), getData(), //{columnStyles: {steps: {columnWidth: 65}}},
{
theme: 'grid', // 'striped', 'grid' or 'plain'
headerStyles: {
fillColor: [189, 200, 255],
textColor: [12, 1, 1]
},
// margin: { top: 50, left: 20, right: 20, bottom: 0 },
styles: {
overflow: 'linebreak',
columnWidth: 110,
lineWidth: 2,
lineColor: [85, 51, 27]
},
pageBreak: 'avoid',
beforePageContent: function(data) {
doc.setFontSize(10);
doc.text("Process Name :"+mainData.name+" || "+"Description :"+mainData.description, 20, 15);
},
//startY: doc.autoTableEndPosY() + 20,
columnStyles: {
//0: {columnWidth: 200}
}
});
//doc.save("xxx.pdf");
Try changing the pdfsize , below are the formats
pageFormats = { // Size in pt of various paper formats
'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94],
'a2': [1190.55, 1683.78], 'a3': [841.89, 1190.55],
'a4': [595.28, 841.89], 'a5': [419.53, 595.28],
'a6': [297.64, 419.53], 'a7': [209.76, 297.64],
'a8': [147.40, 209.76], 'a9': [104.88, 147.40],
'a10': [73.70, 104.88], 'b0': [2834.65, 4008.19],
'b1': [2004.09, 2834.65], 'b2': [1417.32, 2004.09],
'b3': [1000.63, 1417.32], 'b4': [708.66, 1000.63],
'b5': [498.90, 708.66], 'b6': [354.33, 498.90],
'b7': [249.45, 354.33], 'b8': [175.75, 249.45],
'b9': [124.72, 175.75], 'b10': [87.87, 124.72],
'c0': [2599.37, 3676.54], 'c1': [1836.85, 2599.37],
'c2': [1298.27, 1836.85], 'c3': [918.43, 1298.27],
'c4': [649.13, 918.43], 'c5': [459.21, 649.13],
'c6': [323.15, 459.21], 'c7': [229.61, 323.15],
'c8': [161.57, 229.61], 'c9': [113.39, 161.57],
'c10': [79.37, 113.39], 'dl': [311.81, 623.62],
'letter': [612, 792],
'government-letter': [576, 756],
'legal': [612, 1008],
'junior-legal': [576, 360],
'ledger': [1224, 792],
'tabloid': [792, 1224],
'credit-card': [153, 243]
};
You have to say as var pdfsize = 'a1';

Google map in tcpdf not showing correct path

Below is the static url I am using in tcpdf:
http://maps.google.com/maps/api/staticmap?zoom=14&size=800x800&maptype=roadmap&markers=color:green|label:A|52.3693824,4.8871682&markers=color:green|label:B|52.369369,4.901235&markers=color:red|label:C|52.3585252,4.8808168&path=color:66ACF2|weight:3|enc:uks~Haoy\iDOCp#Ap#pGVV?#o#B_Db#MXSCsDrBaDN[S_#S_#?Mn#}I?uDIu##aBBw##o#LoCHmA?s#AoDI_CA_AJ{FH{BD]h#kBT_AJSLKRIZMFAEm#m#oDG[U[wBeCuBcCIMI]GgACWG?I?GCQUGGG#SUGAK#}#tCiBhGs#dC[z#QTQJe#L{ALoHb#M?K~#WrAEHNNt#l#jB|AvFrFhAbAfAfAnBjB~#|#LDJBRj#tAxE^rAt#jCPn#VAn#BZLf#T#F~Dn#RLVLtCn#nD|#ZADCvBj#zBj#AV_BbUbB|A~BrBjAdAz#d#RPx#pAm#bBo#|A[z#?H?B?#M\vAnItGr_#HTx#i#z#g#zByAHIHEAWo#wD_AmF&sensor=false
I think due to the encryted path, tcpdf is not parsing this and showing wrong path in google maps.
Can someone help me regarding this? Thanks in advance!!
Use writeHTMLCell() & <img> html tag:
$html = <<<EOD
<img border="0" src="//maps.google.com/maps/api/staticmap?zoom=14&size=800x800&maptype=roadmap&markers=color:green|label:A|52.3693824,4.8871682&markers=color:green|label:B|52.369369,4.901235&markers=color:red|label:C|52.3585252,4.8808168&path=color:66ACF2|weight:3|enc:uks~Haoy\iDOCp#Ap#pGVV?#o#B_Db#MXSCsDrBaDN[S_#S_#?Mn#}I?uDIu##aBBw##o#LoCHmA?s#AoDI_CA_AJ{FH{BD]h#kBT_AJSLKRIZMFAEm#m#oDG[U[wBeCuBcCIMI]GgACWG?I?GCQUGGG#SUGAK#}#tCiBhGs#dC[z#QTQJe#L{ALoHb#M?K~#WrAEHNNt#l#jB|AvFrFhAbAfAfAnBjB~#|#LDJBRj#tAxE^rAt#jCPn#VAn#BZLf#T#F~Dn#RLVLtCn#nD|#ZADCvBj#zBj#AV_BbUbB|A~BrBjAdAz#d#RPx#pAm#bBo#|A[z#?H?B?#M\vAnItGr_#HTx#i#z#g#zByAHIHEAWo#wD_AmF&sensor=false" alt="Greenwich, England">
EOD;
$pdf->writeHTMLCell('', '', 0, 0, $html, 0, 1, false, true, 'L', false);
Result:
Update:
You also can use Image():
$pdf->Image(
'http://maps.google.com/maps/api/staticmap?zoom=14&size=800x800&maptype=roadmap&markers=color:green|label:A|52.3693824,4.8871682&markers=color:green|label:B|52.369369,4.901235&markers=color:red|label:C|52.3585252,4.8808168&path=color:66ACF2|weight:3|enc:uks~Haoy\iDOCp#Ap#pGVV?#o#B_Db#MXSCsDrBaDN[S_#S_#?Mn#}I?uDIu##aBBw##o#LoCHmA?s#AoDI_CA_AJ{FH{BD]h#kBT_AJSLKRIZMFAEm#m#oDG[U[wBeCuBcCIMI]GgACWG?I?GCQUGGG#SUGAK#}#tCiBhGs#dC[z#QTQJe#L{ALoHb#M?K~#WrAEHNNt#l#jB|AvFrFhAbAfAfAnBjB~#|#LDJBRj#tAxE^rAt#jCPn#VAn#BZLf#T#F~Dn#RLVLtCn#nD|#ZADCvBj#zBj#AV_BbUbB|A~BrBjAdAz#d#RPx#pAm#bBo#|A[z#?H?B?#M\vAnItGr_#HTx#i#z#g#zByAHIHEAWo#wD_AmF&sensor=false',
0.5, 0.5, 20, 20, '', '', '', false, 300
);
It show path line correctly:

Resources