I am trying to load an image from oracle database Blob file. To load image i am using the following code
$COM_CODE = 'O003';
$sql = 'select DIGI_SIGN from LC_BLOCK_LIST_TECH_PERS where COM_CODE :COM_CODE';
$s = oci_parse ($c, $sql);
oci_bind_by_name($s, ':COM_CODE', $COM_CODE);
oci_execute($s, OCI_NO_AUTO_COMMIT);
$arr = oci_fetch_assoc($s);
$result = $arr['DIGI_SIGN']->load();
$pdf->Cell(40,5,$result,0,1,'L',0);
Nedd to show the image in a cell. In last cell i am not able to show the image instead binary value shows up.
what am i doing wrong here?
from here, it looks like you need to first create a file, then use standard procedure to write the image to the pdf:
$result = $arr['DIGI_SIGN']->load();
// Here: new question: [php] how to write image file from Oracle BLOB?
// $result goes to a file on server: "/var/appli/img/products/image1.jpg"
$image1 = "/var/appli/img/products/image1.jpg";
$pdf->Cell( 40, 5, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 30), 0, 1, 'L', 0);
Hope it helps.
Related
I am using JPGraph to generate a graph, the hope is to then save the graph to the file system and point to it in a laravel view. I am attempting to render that view into a PDF later (this is why I'm not generating the chart on the fly).
The problem I am having is I can't figure out how to get the Stream method in JPGraph to save to the Laravel file system.
$graph = new Graph\PieGraph(350, 250);
$graph->title->Set("A Simple Pie Plot");
$graph->SetBox(true);
$legends = ['A (%d)','B (%d)','C (%d)','D (%d)','E (%d)',];
$data = array(40, 21, 17, 14, 23);
$p1 = new Plot\PiePlot($data);
$p1->SetLegends($legends);
$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#DC143C', '#BA55D3'));
$graph->legend->SetPos(0.5,0.98,'center','bottom');
$graph->Add($p1);
$image = $graph->img->Stream(/* TO LARAVEL STORAGE */);
I have tried pointing directly to the path using storage_path('images\graphs\test.png'); but I get a permissions error.
Help, How can i print image excel report?
Please, help me?
I use xlsxwriter.
Example of xlsxwriter
This is my code:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = Image.open(io.BytesIO(imgdata))
# imgdata = base64.b64decode(product_image)
# image = io.BytesIO(imgdata)
print type(image)
sheet.insert_image(rowx, 12, str(image))
The error is:
warn("Image file '%s' not found." % force_unicode(filename))
How to solve?
My goal is print product image in odoo.
Something like the following should work:
product_image = product_product.product_tmpl_id.image
imgdata = base64.b64decode(product_image)
image = io.BytesIO(imgdata)
worksheet.insert_image('B5', 'myimage.png', {'image_data': image})
See the insert_image() section of the XlsxWriter docs and this example of inserting images from an io.BytesIO byte stream into a worksheet.
guys i use TCPDF library for my php server and i want to create a label with width:57mm and height:32mm
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage('L', array(57,32));
$pdf->SetFont('dejavusans');
$html ="
<table class='domi'>
<tbody >";
for($i=0; $i<$rows; $i++){
$style=' style="font-size:'.$fontsize[0][$i].'px"';
if($bold[0][$i]===0){
$html2a[$i] = "<tr><td".$style.">".$content_line[$i]."</td></tr>";
} else {
$html2a[$i] = "<tr><td".$style."><b>".$content_line[$i]."</b></td></tr>";
}
$html2b .= $html2a[$i];//$pdf->GetStringWidth($html2a[$i])." ";
}
$html3 = "</tbody>
</table>";
$pdf->writeHTMLCell($w=55, $h=2, $x='1', $y='1', $html.$html2b.$html3, $border=1, $ln=1, $fill=0, $reseth=false, $align='C', $autopadding=true);
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . 'Site/labels/label'.$id.'.pdf', 'FI');
1st of all it prints the contents fine from the database in A4 size etc but all i want is to create and save the pdf document in the label size width:57mm and height:32mm!!! https://i.stack.imgur.com/kQ8Be.png
as you see, I've marked with 1-5 numbers the actual data and the rest are marked with questionmarks!! I dont understand why of course.
2nd when i change the line $pdf->AddPage('L', array(57,32)); to $pdf->AddPage('L', array(57,57)); the label is created but i have an empty space in the bottom-right corner + it doesnt have the 32x57 size!!! https://i.stack.imgur.com/XgEWU.png
thanks in advance!!!
it seems that i had missconfigured my TCPDF library...
the simple solution that i came up was to put this line
$pdf->SetAutoPageBreak(true, 0);
after this
$pdf->SetFont('dejavusans');
and the result was perfect!!!
https://i.stack.imgur.com/hGwyR.png <-perfectly configured label
https://i.stack.imgur.com/khs9v.png <-wrongly configured label
but in my case it perfect for the job!!! all i want is to preview the result before saving (i mean saving the wrong configuration and then update the base until the configuration is good!!)
I have a PDF with fillable forms. I can successfully fill the forms and save the new PDF to my server no problem, but I cannot place an image on the PDF. When I remove the Image(....) line the script works great. When I add it back it I get the error.
I think it's trying to look for the method in the wrong file, originally I only included fpdm..php but I tried adding back fpdf.php and it did not help. Not sure what I'm doing wrong.
Error:
Fatal error: Call to undefined method FPDM::Image() in /home/.../formPDF.php on line 113
Code:
require('../forms/pdf/fpdf.php');
require('../forms/pdf/fpdm.php');
$pdf = new FPDM($formPDFLocation);
$pdf->Image('images/sig_37-1405313221.png', 100, 20);
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$filename= "../forms/generated/" . $ffID;
$pdf->Output($filename.'.pdf','I');
FPDM is not really related to FPDF but simply a script of a FPDF user. You cannot use FPDF methods on an FPDM instance.
If you search for an all in one solution for such task you may take a look at the SetaPDF-FormFiller component (not free!).
I was able to save the PDF to my server and then add the image but lost the form contents. Code for anyone that is interested in this half solution:
Code for adding image:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("16.pdf");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->Image('car.jpg',20,100);
$pdf->Output();
?>
I'm trying to theme one of my content types, which has images uploaded to each instance using the image attach module.
Using the developer module, I've found the iids value of the uploaded image (eg 305), but i'm having trouble finding out how I can actually display the image in my code. This line outputs the node id of the image which has been uploaded, but how can I then use that?
$image = $node->iids[0];
I've tried using hook_image, but I can't seem to get that working...
Thanks for any help.
This did the trick...
$nodeid = $node->nid;
$get_image = db_query('
SELECT p.filepath as imagefilename
FROM {image_attach} i
LEFT JOIN {image} a ON i.iid = a.nid
LEFT JOIN {files} p ON a.fid = p.fid
WHERE i.nid = %d AND p.filename = "recipe_thumb"', $nodeid);
$obj_image = db_fetch_object($get_image);
$imagefilename = $obj_image->imagefilename;