I cannot include an image in a TCPDF header - tcpdf

To create a custom header and footer, I used TCPDF's header() and footer() functions, but when I try to include an image in the header using the function $this->image(), the image cannot be displayed. Other images in the document are working fine.

Try this example:
$pdf->SetHeaderData("image.jpg", PDF_HEADER_LOGO_WIDTH, "Application PDF", "Application Form\nRaining Pesos, Inc. - www.rainingpesos.com");
The first parameter is where you put the image on the header, but make sure on your path image config,
define ('K_PATH_IMAGES', '/images/');
make sure the images that you want to display on the pdf is in the folder you set, in this example the folder 'images' contains the 'image.jpg'.
Hope it helps!

Related

Inline-embedded image in Internet Shortcut .URL file?

I have tried to inline-embedding an image inside an Internet Shortcut .URL file:
[InternetShortcut]
URL=https://de.wikipedia.org/wiki/Data-URL
<img src="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="red dot" />
The aim is to display the shortcut file as an image (in this case a red dot image) in Windows File Explorer.
Unfortunately, the above code example does not work in the intended way.
Is it generally possible at all to inline-embed an image inside an Internet Shortcut .URL file in a similar way?
You can't include an img-tag into an .url file. The file is structured like an .ini file in Windows.
However, it is possible to link an icon (.ico) file by specifying IconFile.
cf. https://superuser.com/questions/898669/what-makes-internet-shortcut-files-special

TCPDF - Header image only displays on first page

I am using TCPDF to generate a 2 page pdf document.
I have added a header and a footer to the document. The text part of the header and footer shows up correctly on each page however when I include an image logo in the header it is only showing up on the first page.
public function Header()
{
$this->Image('/home/xxxxxx/public_html/xxxxxxxx/uploads/logo/logo.png',10,6,0,13);
$this->SetFont('helvetica','B',20);
$this->Cell(80);
$this->Cell(0,0, $project->name . ' - Project Plan',$frame,0,'R');
$this->Ln(8);
$this->SetFont('helvetica','',10);
$this->Cell(0,0, $organisation->name,$frame,0,'R');
$this->Ln(10);
}
Does anyone have any idea what I am doing wrong here?
Thanks
I think is not related to header/footer, but I think TCPDF has bug that broken Image function with same image file loaded multiple times as reported here TCPDF - image displayed only once
bug also present on actual version tecnickcom/tcpdf:6.2.26
I resolve this problem by loading image outside and pass to the function as string.
public function Header()
{
$this->Image('#'.file_get_contents('/home/xxxxxx/public_html/xxxxxxxx/uploads/logo/logo.png'),10,6,0,13);
$this->SetFont('helvetica','B',20);
$this->Cell(80);
$this->Cell(0,0, $project->name . ' - Project Plan',$frame,0,'R');
$this->Ln(8);
$this->SetFont('helvetica','',10);
$this->Cell(0,0, $organisation->name,$frame,0,'R');
$this->Ln(10);
}
As said it is a tcpdf bug. In my case I had two logos in header one png and the other jpg. The problem happened only with the .png. Changing the image type from png to jpg solved the issue.
I solved this by using base64 encoded string like this:
$image = base64_encode(file_get_contents('path_to_image'));
Then you can use it like this:
<img src="#<?= $image ?>" />

sapui5 UploadCollection - unable to set correct icon

I try to use sap.m.UploadCollection to display attachments. Here is the example from Sap explored:
However, for my documents, I get always this icon:
I checked mimetype is set correctly for the item, filetype is set as well for the uploadcollection.
Do you know where is the trick?
I found the reason:
UploadCollection icon is mapped not to the mimetype specified, but to the filename property. So if the filename is returned without extension, like "Notes" instead of "Notes.txt", then no icon is displayed.
I still do not get why sap wants to parse filename to get extension from it, where mimetype property is 100% suitable for its purpose,
but this is the solution - provide fill filename.

how to load url from txt file and usng imacro

I have imacro enterprize edition. I want to load URL from a .txt file and visit the pages, and then fill a form. The form is the same for all the URLs. For a single page, I can make the macro but cannot make the macro that load the next URL from a .txt file and do the same work.
I have searched a lot and made a code that can load an URL from .csv file and visit a page. But it is not working. Here it is:
VERSION BUILD=7401004 RECORDER=FX
TAB T=1TAB CLOSEALLOTHERS
SET !DATASOURCE input.csv
SET !DATASOURCE_COLUMNS 7
SET !DATASOURCE_LINE {{!LOOP}}URL GOTO={{!COL1}}
What might I be doing wrong?
You have to define a variable for the loop:
VERSION BUILD=8940826 RECORDER=FX
SET !DATASOURCE c:\input.csv
SET !DATASOURCE_COLUMNS 7
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO={{!COL1}}
...

Get the filepath of an image inserted into TWebBrowser in edit mode

When you insert an image into a TWebBrowser in edit mode, how do you get the filepath of the inserted image? When an image is inserted it includes the full path to the image in the html source, but in my case I need to modify the html source to only include the filename.
EDIT:
This is the html source after the image is inserted:
<IMG border=0 hspace=0 alt=delphi align=baseline
src="C:\Images\delphi.bmp">
I need to change
<IMG border=0 hspace=0 alt=delphi align=baseline
src="C:\Images\delphi.bmp">
to
<IMG border=0 hspace=0 alt=delphi align=baseline
src="HTML\delphi.bmp">
Yes I can get the path from the html but I'd like to try to copy the image file to the HTML folder then change the path to the HTML folder after the image is inserted without parsing the html. If the filepath can be obtained after the image is inserted I can add the code to copy the file to the HTML folder so that the image appears in the webbrowser with the new path...
Have you tried using the browser's DOM interfaces to read the src attribute and update it to what you want? Specifically, look at the src property of the IHTMLImgElement interface.

Resources