I cant make a dynamic image path in pdf - image

I've been trying to display an image in a fpdf file, it only works when I specify the exact location of the image. Can I make it dynamic?
Heres sample line of code:
$this->Image('fpdf/img/logo1.png',10,6,30);
and it works when I turn this way:
D:\Installed Apps\New
folder\XAMPP\htdocs\votingsystem\application\views\admin\senior\fpdf\img\logo1.png',10,6,30);
I want to transfer it to another laptop, I'm afraid it wont work.
I always get this error:
Message: fopen(fpdf/img/logo1.png): failed to open stream: No such
file or directory
I use code igniter as framework.

You can use multicell option in fpdf. I use this below code in php to it working.
`
define('ASSETS_URL','Your url or path to image file');
$yaxix = $pdf->GetY();
$xaxix = $pdf->GetX();
$pdf->MultiCell(50,10.5,$pdf->Image(ASSETS_URL.'/img/your-image-name.jpg',$xaxix,$yaxix+5,50)."\nAuthorised Signatory",1,'C',FALSE);
`
In this case you only have to change constants.

Related

Can not set font for html2pdf in Laravel app

In laravel 5.7 app I work with spipu/html2pdf 5.2 to generate piece of html/bootstrap code
into pdf file and I have a problem with font definition
My pages use Roboto font, but if I make :
$html2pdf = new HTML2PDF('P','A4','en', true, 'UTF-8');
$html2pdf->addFont('Roboto', '', public_path('/fonts/roboto/Roboto_regular.ttf'));
I have font in my app /fonts/roboto/Roboto_regular.ttf
and I can preview it : https://prnt.sc/tgcgjq
$html2pdf->WriteHTML(htmlspecialchars_decode($pdf_content));
$html2pdf->Output($save_to_file,'F');
But I got error :
TCPDF ERROR: The font definition file has a bad format: /mnt/_work_sdb8/wwwroot/lar/the-box-booking/public/fonts/roboto/Roboto_regular.ttf
The difference in path is that I use links :
ln -s /mnt/_work_sdb8/wwwroot /_wwwroot
If I try to use times font(which I want to use for generated pdf file) as
$html2pdf->addFont('times');
I got error :
TCPDF ERROR: Could not include font definition file: &#039
looks like in last case fontname is not set , but I do not know how have I to set it ?
I have times set in my OS, I suppose I do not to put it under /public/fonts/?
Thanks!

Sketchup ruby definitionlist load method error: Invalid component file

When I create a script file and load it from the console with:
load '//192.168.0.0/Mağaza/script.rb'
I get 'Invalid component file' error for:
someModel = Sketchup.active_model.definitions.load '//192.168.0.0/Mağaza/Definitions/model.skp'
But when running the code directly in console, it works.
Any idea why?
DefinitionList.load is a completely different method from Ruby's load.
To load a component from a URL you need to use model.definitions.load_from_url:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/definitionlist#load_from_url
After two days, I figured out that the problem was the encoding of 'ğ' in the folder name (mağaza). I tried ANSI and UTF-8 encoding in my script file but nothing changed. But when print the path name in the console, it turned out that the character was not encoding properly.

codeigniter custom config file calling config data

i've a file # /config/form_validation.php
i've another file # /config/ion_auth.php
i tried to get the 'ion_auth data' in form_validation but failed:
'rules'=>'required|min_length['.$this->config->item('min_password_length', 'ion_auth').']'
error Message: Undefined property: CI_Loader::$config
If i change it to this, all works well.
'rules'=>'required|min_length[3]'
It seems that i cannot call the data from another config file at the current config file.
How to overcome this problem or is this a system limitation?
it seems you create form at wrong place, try to get main controller first:
$CI =$ get_instence();
'rules'=>'required|min_length['.$CI->config->item('min_password_length', 'ion_auth').']'

Can't find variable: StageWebViewBridge

I use the development tools:Adobe Flash Builder 4.6;
When I move the 'ExampleCallBackFuncions?.html' to an online server and try to load it using:
webView.loadURL("http://192.168.1.101/MapTest/ExampleBasic.html");
The html page appears but when I press the callAS3Function button I get the following error:
ReferenceError?: Can't find variable: StageWebViewBridge? callAs3Funciton at http://www.myserver.com/ExampleCallBackFuncions.html : 14
onclick at http://www.myserver.com/ExampleCallBackFuncions.html : 27
Create flex mobile project is how to interact with , and I can not always interact?
Thanks;
You need to include the project:
http://code.google.com/p/stagewebviewbridge/
It seems the file StageWebViewBridge.js is missing.
When we use stagewebviewbridge, we should include StageWebViewBridge.js file in our .html file, because, though the .js file we can make communication between as3 and js. So you could include the .js file location in your .html file.
You better to have the .js file as part of your [ MapTest ] directory, or refer .js from http://code.google.com/p/stagewebviewbridge/

Missing xml tag SVG file (using Graphviz dot.exe)

My config is:
- Windows Vista
- XAMPP 1.7.1
- Media Wiki + Semantic MW
- an extension that uses Graphviz to create a SVG
- Graphviz 2.26.3 (install dir c:\graphviz.....)
Everything works fine but the problem is: the xml tag
'image xlink:href="some_image.png"....'
is missing from the SVG file created using a Media Wiki php page.
This is done by:
$cmdlinesvg = wfEscapeShellArg($cmd).' -T svg '.wfEscapeShellArg($src).' -o '.wfEscapeShellArg($svg);
$WshShell = new COM("WScript.Shell");
$WshShell->Exec($cmdlinesvg);
I've created a batch file that executes the same command line:
c:\graphviz2.26.3\bin\dot.exe -T svg filename.dot -o filename.svg
and if I run it manually it works, and the xml tag appears.
Anyone knows what is the problem? thanks in advance.
SOLVED
The problem is related to the image path that is in the .DOT file.
If you run the command line manually, the image path doesn't need to be a full path.
You can have only: shapefile="some_image.png"
If you run the command inside php code, the image path HAS to be a full path.
So you must have: shapefile="C:\xampp......\some_image.png"
Another problem arises: the resulting .SVG file doesn't show the images.
If you right-click and open the .SVG file with the browser (ie Firefox), the images are ok.
But, again, through a php page, the images are lost.
Solution: edit the .SVG file (this is XML) to change the paths.
On the original .SVG file we have:
On the modified .SVG file we must have:
PS: I'm doing my master thesis, so this is for a particular problem, but still I hope it helps someone.

Resources