I have gone through this link for the barcode generation.
I have downloaded the zip file and tested in my local host. It worked there, after that I have kept the files in my project and checked there. It doesn't work instead it gave me corrupted image as below.
GIF87aP���������,P���������p�قzu���b�a�I���xmZơFÌ,��}r�~���[�pH��(��>V�ie����q����dZΰ�+�����'�=]��n9?^wv�g��W���UƵ���h�8x(h�����GG� I��z�I:�j�y*zY�ij�::[� �Z+p+�J�k�Z�K�k�|��L�)����`N���qt���r���"�P���>�NA<~��]�p��{���!D +Z�ؠ;
Now I've created a sample file in the same location in my project with simple <?php ?> tags and kept the code
include "Barcode39.php";
// set Barcode39 object
$bc = new Barcode39("abc");
// display new barcode
$bc->draw();
again it worked in the sample file which I have kept in the project, but it is not working in the project related file.
Not getting the issue here.
Its perfectly working fine, make sure Barcode39.php in the same location.
As well it required PHP:GD, check again its install or not.
(Include could be issue if you are using any other framework)
I tested and got the below output
You can also use the below code to generate the gif file of barcode and link it anywhere in any page. you will not face any issue related to using html tags.
<?
// include Barcode39 class
include "Barcode39.php";
// set object
$bc = new Barcode39("123-ABC");
// set text size
$bc->barcode_text_size = 5;
// set barcode bar thickness (thick bars)
$bc->barcode_bar_thick = 4;
// set barcode bar thickness (thin bars)
$bc->barcode_bar_thin = 2;
// save barcode GIF file
$bc->draw("barcode1.gif");
?>
and include this file in the src attr of the image tag like
<img src="http://localhost/yourbarcodefilepath" alt="barcode"/>
then it will work
Related
There is a simple two-column table on a website: product name and product image. It's very easy to render in HTML.
The task would be creating an Xlsx file with these columns.
The images are not stored locally but all of them are remote images with full URL.
The export contains ~100-200 rows.
I tried to create a resource with imagecreatefromjpeg and adding it with MemoryDrawing but it took a huge amount of resources.
I tried with Html helper's toRichTextObject and a simple tag but got empty result.
How is it possible to add a remote image to a PhpSpreadsheet cell? It doesn't need working offline, it's fine to load the remote images when the file is opened.
As #FabriceFabiyi mentionned in his comment, and after reading:
PhpSpreadseet documentation on drawing.
PHP documentation on file_get_contents.
PHP documentation on file_set_contents.
This worked for me:
$image = file_get_contents('https://website.com/path/to/image');
$imageName = 'a_nice_image_name';
//You can save the image wherever you want
//I would highly recommand using a temporary directory
$temp_image=tempnam(sys_get_temp_dir(), $imageName);
file_put_contents($temp_image, $image);
// And then PhpSpreadsheet acts just like it would do with a local image
$drawing->setPath($temp_image);
$drawing->setHeight(36);
$drawing->setWorksheet($sheet);
$drawing->setCoordinates('B15');
More on temporary directories in the PHP docs:
sys_get_temp_dir()
tempnam()
There is an example how add image to your excel export:
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$drawing->setName('Paid');
$drawing->setDescription('Paid');
$drawing->setPath('/images/image-1.png'); // put your path and image here
$drawing->setHeight(30);
$drawing->setCoordinates('A5');
$drawing->setOffsetX(110);
$drawing->setRotation(25);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($spreadsheet->getActiveSheet());
Specifying coordinates for the image might help, as per the examples and the documentation
$objDrawing->setCoordinates('A3');
Note that an image isn't in a cell/column/row, but overlaid over the main sheet at the same position as that cell/column/row
I saw many post about changing picture in OpenTBS but I don't understood how to do that.
I have a .odt file wich has an image and i need to replace it from php with another one.
From documentation i see the Exemple: [ onshow.x;ope=changepic] but I have no idea where I have to put this line.
I've also tried to use this code below but nothing happens.
"ticket.odt" has an image (it has $PicRef descripton) which I would like to change.
$TBS= new clsTinyButStrong;
$TBS->PlugIn(TBS_INSTALL, OPENTBS_PLUGIN);
$TBS->LoadTemplate("Ticket/ticket.odt");
$TBS->PlugIn(OPENTBS_CHANGE_PICTURE, $PicRef, $logo );
As documentation $PicRef is a string that is saved in the Title or the Description of the picture and $logo is the path for picture file that will be copied inside the document
Could someone explain me how it'works and what i have to do?
Example using command OPENTBS_CHANGE_PICTURE:
PHP side:
$TBS->PlugIn(OPENTBS_CHANGE_PICTURE, 'my_picture', 'logo.png');
$TBS->Show(OPENTBS_FILE, $file_name);
Template side:
In the ODT template do a right-click on the picture you want to be replaced then you have the contextual menu. In the contextual menu, select Properties. Then in the tab Options, change the property Name to 'my_picture'.
When running the script, the picture will be replaced.
Example using parameter changepic:
PHP side:
$TBS->VarRef['x'] = 'logo.png';
$TBS->Show(OPENTBS_FILE, $file_name);
Template side:
Put the TBS field [onshow.x;ope=changepic] somewhere in the normal text after the picture you whant to be changed.
Or
Put the TBS field [onshow.x;ope=changepic;tagpos=inside] in the property Name of the picture (see previous example).
I'm trying to include the aquaresize script in my theme. I have added it to assets/components/aq_resize.php
And required it in functions.php
require_once( 'assets/components/aq_resize.php' );
However, when I try to echo
aq_resize($img_url,$width);
Nothing is shown on the page, I gave the variables $img_url a url and $width a number
When I make a console.log in assets/components/aq_resize.php I can see the log in my console.
Why doesn't my aq_resizer work?
The aqua resizer code can be found here: https://github.com/syamilmj/Aqua-Resizer/blob/master/aq_resizer.php
To test it I used a random image from google.
<?php
$img_url = 'http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg';
$width = 300;
echo aq_resize($img_url,$width);
?>
Some common issues that prevent aq_resizer.php working:
Make sure that the original image has dimensions larger than the new dimensions you want to resize to.
Go to your wordpress admin dashboard > Settings > Media, and make sure that your media library folder is simply 'wp_content/uploads'. (If there is no field available to set the folder, then it's already set to 'wp_content/uploads')
I have solved the problem by activating "gd" library for xampp. You simply have to install/activate gd library. Go to php.ini file and check if "extension=gd" starts with ";". If it starts with ";" simply remove it. Otherwise insert a new line extension=gd.
This is an odd question but I'm stuck on how I would achieve this and I am unable to find any methods of doing so.
I have a simple php script that takes variables (containing file names) from the URL, cleans then and then uses them to generate a single image from the inputted values. This works fine and outputs a new png to the webpage using:
imagepng($img);
I also have a facebook sharing script in PHP that takes a filepath as an input and then shares the image on the users feed where this statement is used to define the image variable:
$photo = './mypic.png'; // Path to the photo on the local filesystem
I don't know how I can link these two together though. I would like to use my generation script as the image to share.
Can anyone point me in the right direction of how to do this? I am not the master of PHP so go easy please.
-Tim
UPDATE
If it helps, here are the links to the two pages on my website containing the outputs. They are very ruff mind you:
The php script generating the image:
http://the8bitman.herobo.com/Download/download.php?face=a.png&color=b.png&hat=c.png
The html page with the img tag:
http://the8bitman.herobo.com/Share.html
Treat it as a simple image:
<img src="http://yourserve/yourscript.php?onlyImage=1" />
yourscript.php
if($_GET['onlyimage']) {
header('Content-type:image/png'); //or your image content type
//print only image
} else {
//print image and text too
}
I'm going to use JpGraph in my web-project. To do this, I downloaded the library into my project folder and created the following test code:
<?php
include ( "jpgraph-3.5.0b1/src/jpgraph.php");
include ("jpgraph-3.5.0b1/src/jpgraph_gantt.php");
// A new graph with automatic size
$graph = new GanttGraph (0,0, "auto");
// A new activity on row '0'
$activity = new GanttBar (0,"Project", "2001-12-21", "2002-02-20");
$graph->Add( $activity);
// Display the Gantt chart
$graph->Stroke();
?>
The error message is:
The image “http://localhost:10088/test/check.php” cannot be displayed,
because it contains errors.
What's wrong with my code? In fact, it was just copied from here. The only thing I changed was the path to the JpGraph library. So, do I need to import this library in some special way into my project (so far, I've just copied the JpGraph's folder into the project's folder)? I'm using Zend Studio.
This can be caused by extra whitespace on the page. Make sure you don't have any spaces or line breaks before your opening <?php tag.