Can't write my table to PDF using WriteHTML in codeigniter - codeigniter

Im trying to print my table to PDF using the mpdf library in CodeIgniter, but I can't get the data
I'm using into the mpdf library. When I echo my $table, I can see/preview it, but when I write it to PDF, no data appears. Can someone help me? Thanks in advance..
$mpdf = new mPDF('', // mode - default ''
'', // format - A4, for example, default ''
7, // font size - default 0
'arial', // default font family
10, // margin_left
10, // margin right
5, // margin top
5, // margin bottom
2, // margin header
2, // margin footer1
'L'); // L - landscape, P - portrait
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($table);
$mpdf->Output();

Look for any whitespaces before <?php and after ?> (if exists) and remove them.
If that not work, post more php code please.

Related

Display column numbers on top of each column using tcpdf html

Example of what I want to achieve in the image
Everything works well except that I want to display the column numbers on top of each columns.
And also remember the content of each column for indexing purposes.
How can I display column numbers in tcpdf documents?
$pdf->AddPage();
// set columns
$pdf->setEqualColumns(3, 50);
// print chapter body
$pdf->selectColumn();
// set font
$pdf->SetFont('helvetica', '', 9);
$pdf->SetTextColor(50, 50, 50);
$pdf->writeHTML(stripslashes($columns), false, false, true, false, 'J');
$pdf->Ln();

Codeigniter 4 image watermark

I'm using the codeigniter's Image Manipulation Class and would like to watermark
an image with an another image?
It was working fine in CI3, but I cant find it in CI4.
In the documentation there's only a possibility to watermark with text. https://codeigniter4.github.io/userguide/libraries/images.html#adding-a-text-watermark
CI4 does not support such a feature, you can use this script and make it work with CI4
<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
https://www.php.net/manual/en/image.examples-watermark.php

Sub 10 height request layouts/views not allowed

I'm trying to add line dividers between views. However, there is a forced margin on every element I try (Image, BoxView, Frame, Label). I set the margin to be 0, the HeightRequest is always 3, but as you can see the view bounds expand past the actual view. Is there a specific view I'm supposed to be using? I just want the gray line and nothing more.
var line2 = new Frame
{
WidthRequest = (App.ScreenDpWidth / 2),
MinimumHeightRequest = 3,
HeightRequest = 3,
BackgroundColor = Color.FromHex("#229EBB"),
Margin = new Thickness(0, 0)
};
I assume you are layouting your elements either in a Grid or a StackLayout.
By default, the StackLayout.Spacing, Grid.RowSpacing and Grid.ColumnSpacing properties are set to 6d.
Without more information, I think that's what you're seeing in your code. Change those values to 0d.
Also, if you only want a gray line, you can use a BoxView which will draw a gray box, and set it's Height to 1d.

PDFKit, Not able to open the pdf generated

I am trying to generate a pdf using some texts of my own (and not a html page). I tried using PDFKit. I am able to generate the pdf but then I am not able to open it in Preview (It may be damaged or use a file format that Preview doesn’t recognize.)
Below is the code,
var fs = require('fs');
PDFDocument = require ('pdfkit');
var doc = new PDFDocument
// Embed a font, set the font size, and render some text
doc.text('Some text with an embedded font!', 100, 100)
// Add another page
doc.addPage()
.text('Here is some vector graphics...', 100, 100)
// Draw a triangle
doc.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill("#FF3300")
// Apply some transforms and render an SVG path with the 'even-odd' fill rule
doc.scale(0.6)
.translate(470, -380)
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
.fill('red', 'even-odd')
.restore()
// Add some text with annotations
doc.addPage()
.fillColor("blue")
.text('Here is a link!', 100, 100)
//.underline(100, 100, 160, 27, color: "#0000FF")
.link(100, 100, 160, 27, 'http://google.com/')
// Write the PDF file to disk
doc.pipe(fs.createWriteStream('out.pdf') );
doc.end
I might be missing something small. P
It was a silly mistake on my part. I should have used doc.end() instead of using doc.end and due to this the pdf was not getting generated properly.

Display Lines AND Points on the Line Chart - Google Visualisation API

Is it possible to represent one data series as points and another as lines?
In the chart below I want the blue 'Data' line to be represented as points whilst retaining the other series as lines, can this be done using the Google Visualisations?
I generated the graph above in this fiddle using the following code
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn('number', 'Data');
data.addColumn('number', 'High');
data.addColumn('number', 'Low');
data.addRow(["A", 1, 5.5, 2.3]);
data.addRow(["B", 2, 5.5, 2.3]);
data.addRow(["C", 7, 5.5, 2.3]);
data.addRow(["D", 3, 5.5, 2.3]);
data.addRow(["E", 6, 5.5, 2.3]);
data.addRow(["F", 5, 5.5, 2.3]);
// Create and draw the visualization.
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, {
width: 500, height: 400}
);
}
Yes you can!
http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html
In that link go to the section on "Series". You can specify each line as a series and set the lineWidth property to 0, overriding the default. That should have the effect of drawing no line and just the data points. In your case you can set the 1st series ("Data") to 0 and leave the rest alone.

Resources