How to get proper image in pdf doc with its height and width using zend_pdf class - zend-framework

I am facing a problem with zend_pdf as I am not getting the quality of the image and actual height and width of the image in zend pdf documents.
below is the function which I am using
$pdf = new Zend_Pdf();
$page = $pdf->newPage('510:745:');
$pdf->pages[] = $page;
$image = Zend_Pdf_Image::imageWithPath($imagePath);
$page->drawImage($image, 100,100,400, 300);
So how can I get the quality of an image with its proper height and width with Zend_pdf?
Thanks

Change the size as original. It would be help to maintain the original quality of the picture.

Maybe getPixelWidth() and getPixelHeight() works better. Like this:
$img = Zend_Pdf_Image::imageWithPath('myimage.png');
$page->drawImage($img, 0, 0, $img->getPixelWidth(), $img->getPixelHeight());

Related

html2canvas toDataURL(image/png") return poor image quality

I tried to use html2canvas to get image screenshot byte from website. However, the screenshot result ended with poor resolution. Looking for advice to improve screenshot quality. Thanks.
How about something like this:
var $wrapper = $("#yourDiv");
setSize($wrapper, "2000px", "20pt");
html2canvas($wrapper, {
onrendered: function (canvas) {
var a = document.createElement('a');
a.href = canvas.toDataURL("image/jpg");
a.download = 'filename.jpg';
a.click();
setSize($wrapper, "1000px", "10pt");
}
});
function setSize(dv, width, fontsize) {
dv[0].style.width = width;
dv[0].style.fontSize = fontsize;
}
This resizes the div and font to bigger size and then shrinks back afterwards.

itext 7 - canvas with customized page

In iText 2 , we can use PdfContentByte to set customized page-size, however, in iText 7.1.2.
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
PdfPage page = pdf.addNewPage();
PdfCanvas pdfCanvas = new PdfCanvas(page);
Rectangle rectangle = new Rectangle(0, 0, 2000, 800);
pdfCanvas.rectangle(rectangle);
pdfCanvas.stroke();
Canvas canvas = new Canvas(pdfCanvas, pdf, rectangle);
PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);
Text title =
new Text("The Strange Case of Dr. Jekyll and Mr. Hyde").setFont(bold);
Text author = new Text("Robert Louis Stevenson").setFont(font);
Paragraph p = new Paragraph().add(title).add(" by ").add(author);
canvas.add(p);
canvas.close();
pdf.close();
even if we set larger width, it didn't work. still keep A4 size. How can i change the pageSize correctly ?
You are adding a new page without specifying a page size, hence the default page size (A4) is used. Please take a look at the API docs for the addPage() method: addNewPage(PageSize pageSize). You need to pass a PageSize argument if you want to get a page with another size.
There's also a setDefaultPageSize() method if you want to change the default page size from A4 to something else.
The PageSize class extends the Rectangle class: http://itextsupport.com/apidocs/iText7/latest/com/itextpdf/kernel/geom/PageSize.html

Square thumbnails

I want to generate a square thumbnail from a sourceimage for a TYPO3 gallery extension, but I don't find a way to do this. It can be a square section from the source image.
To decrease the image proportional to an thumbnail, i use the following function:
function generateImg($w,$h,$fname,$dir,$class,$id){
$imgTSConfig = array();
$imgTSConfig['file'] = $dir.'/'.$fname;
$imgTSConfig['file.']['maxW'] = $w;
$imgTSConfig['file.']['maxH'] = $h;
$imgTSConfig['stdWrap.']['addParams.']['class'] = $cl;
$imgTSConfig['stdWrap.']['addParams.']['id'] = $id;
$timg = $this->cObj->image($imgTSConfig);
return($timg);
}
Try this:
$imgTSConfig['file.']['width'] = '120';
$imgTSConfig['file.']['height'] = '120c';
...instead of (or combined with) maxH and maxW. The 'c' parameter crops the image if it is to high.
Source

Jqplot pie- charts doesn't utilize the full width and height of the div container

Just noticed that the pie-chart that is displayed is not utilizing the full width and height of the container.
I can see some blank spaces. Attached image below.
I have drawn borders to the div. And it is clear that the pie isn't utilizing the full width and height.
How do i get this thing fixed?
Any help would be appreciated.
Thanks in advance.
It looks like the default piechart renderer has a padding of 20px. Reduce it as you see fit by adjusting the padding such as:
jQuery("#'. $id .'").jqplot([your data here],
{
seriesDefaults: {
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
padding: 10
}
}
});

Titanium.UI.Label property height

In my code I am doing this:
var taskLabel = Ti.UI.createLabel({color:'#777', top:3, textAlign:'center', height:'auto', text:task.title});
Ti.API.info('Next info is: taskLabel.height');
Ti.API.info(taskLabel.height);
But, the output from this is:
[INFO] [123,883] Next info is: taskLabel.height
And nothing more, it looks like it breaks silently, but I guess it shouldn't, based on the API.
I am trying to sum some heights of the elements, but I would prefer it behaved like html postion:relative. Anyway, I'd like to read the height in float, how can I achieve that?
You need to set a fixed width when you use an auto height. For example:
var taskLabel = Ti.UI.createLabel({color:'#777', top:3, textAlign:'center', height:'auto', width: 200, text:task.title});
you are not going to get the height until it is actually rendered and added to view or window.
You cant read the height property off like that, if you didn't manually define it.
It has to be added to a view, and then displayed (assuming it doesn't auto display) before Titanium will return anything about the height.
var window = Ti.UI.createWindow();
var taskLabel = Ti.UI.createLabel({color:'#777', top:3, textAlign:'center', height:'auto', text:task.title});
window.add(taskLabel);
window.open();
Ti.API.info('Next info is: taskLabel.height');
Ti.API.info(taskLabel.height);
That should work to show the height.
This should work.
var lbl_obj = Ti.UI.createLabel( { height: 'auto', text:'Test Label', top:10 } );
var height = lbl_obj.toImage().height;
Ti.API.info(height);