I'm using DOMPDF to generate several documents, and in the top left is an image that looks like this:
But whenever I generate the PDF there is a very small chance (let's say about 10%) that the image will look like this:
I have no idea why this happens. It doesn't happen to any other images in the document.
When I move the image a few pixles up or down, the white line moves as well, so it's not like there is a hidden element or something placed over the image.
Is this a known DOMPDF problem ?
It appears that this is caused by imagick. It can be disabled as follows:
Add the following line to "dompdf_config.custom.inc.php":
define("DOMPDF_ENABLE_IMAGICK", false);
And change line 4324 of "class.pdf.php" from:
elseif (extension_loaded("imagick")) {
to:
elseif (extension_loaded("imagick") && DOMPDF_ENABLE_IMAGICK) {
This solution worked for me
I found it here: https://github.com/dompdf/dompdf/issues/432
Thanks to BrianS
Related
Php produces pdf without issue when does not span, nested tables are not in use, and
HTML2PDF::$_subobj->pdf->getPage();
doesn't seem to address the bug/issue. Anyone run into this ERROR n°7?
Add the following in your function to solve the error
html2pdf->setTestTdInOnePage(false);
If you have a long picture (in table td) , example 1200px you can get this error.
I fixed my picture to 600px and problem solved.
Example: My photo is 3000x2000 (width:height)
I resized photo to 600x400.
I'm trying to use DomPDF to generate a PDF out of some HTML. I need the page to be 20mm x 20mm, so I use the following:
CPDF_Adapter::$PAPER_SIZES['my_square_page'] = array(0, 0, 566.929134, 566.929134);
$dompdf->set_paper('my_square_page','portrait');
It works properly, if I check the PDF properties the size is ok. The HTML that will appear in the PDF has a container div of 490x490px. This size cannot be changed, as the elements inside that div are absolutely positioned.
The problem, then, is that in the generated PDF the div does not cover the entire page. I've tried setting the DPI, using different values in
def("DOMPDF_DPI", 150);
But it does not seem to make any difference at all. The output I get is this (gray borders are from the PDF reader):
I've tried setting the width and height of body and html in the CSS of the content, but it does not work.
You can check the source code of my sample case here.
Ok, I figured it out. Looks like the line
def("DOMPDF_DPI", 150);
does not actually do anything. I did change the dompdf_config.custom.inc file and then it worked. Added this:
define("DOMPDF_DPI", 62.230);
But now the images look too big :S
I'm using cakephp 2 and I'm trying to allow my users to upload an image which is then used as the background for their page.
I have the images uploading fine and saving to a (webroot)files/User/$userid/$bodybgimage. I've also got the name of the image in the database.
Trouble is I want because I don't know in advance what user id is going to be requesting their background image I can't put their background in the stylesheet, so I'm trying to get it added in the default layout. I've tried to add with jquery: (the image filename is in $bodybgimage)
<?php if(!$bodybgimage == '') {?>
$('body').css('background-image', 'url('<?php echo '../files/User/'.$userId.'/'.$bodybgimage; ?>')');
<?php }?>
But this seems to just remove everystyle I had for the body!
I also tried doing adding it straight to the body tag like so:
<body<?php if(!$bodybgimage == '') echo ' style="background-image:url(../files/User/'.$userId.'/'.$bodybgimage.')"';?>>
But again to no avail. Can anyone help me out. I know the image and all's there because if I put the background-image style in the stylesheet the image pops up ok. There must be a sensible way to do this that I'm missing. Plz help!
Please can you try to omit the "../" before the files as i assume that your images founded in a folder named files beside your script not ?
How do you remove the image in OpenTBS if the one you are replacing it with does not exist?
I have a bit of code that loops through and replaces pics in a table, but sometimes the client will not have the pictures. I tried leaving out the default=current tag but it shows a missing image box("This image cannot currently be displayed").
UPDATE:
I thought Skrols answer would work but I couldnt get it to work. I have an image followed by the following tag.
[field.p5;ope=changepic;from=’[val]’;adjust]
Whats tags following this would i have to use to say if the field variable p5 is not set or empty ect then remove the image.
If your first need is to not change the picture in the Docx if the target picture is a not found file, then they are two solutions:
First try with the latest OpenTBS version (1.7.4) because it claims to fix a bug about "default=current"
If it does not work, then you have to check at the PHP side if the target picture does exist using file_exists(). If it doesn't exist then change the target picture path with a new file that you are sure it does exist.
If you prefer to delete the picture box in the document if the file is missing, then you can add a TBS field that will delete the picture box depending to a global variable.
PHP:
$picok = (file_exists($the_picture)) ? 1 : 0;
HTML:
[onshow;block=w:drawing;when [var.picok]=1]
I have some thumbnail images with its larger version.I placed the thumbnail images in a page.Now for link I just gave a link
<img src="thumbnail1.jpg>
but for this I have to make different pages for showing larger one.I want to give a link to show them in a single page.means whenever I will click the thumbnail it will open the larger one in a page with the same url but with its name like
imagegallery.php?news=images/largerimage1/13.jpg
imagegallery.php?news=images/largerimage1/14.jpg
so how to do that?
Pretty basic stuff, I suggest you get to read some PHP tutorials on the internet to get some knowledge on one thing and another.
The ?news= part in your URL is a parameter that can be read by PHP. This type is known as $_GET. To get this part you would need $_GET['news'] so if we'd use your first link and place this inside a script: echo $_GET['news']; the page would say images/largerimages1/13.jpg.
In order to get the image loaded on your website we need some simple steps, I'm changing the news parameter into image, that suits better for your script since it ain't news items:
<?php
// Define the path (used to see if an image exists)
$path = 'your/absolute/path/to/public_html/'; # or wwwroot or www folder
// First check if the parameter is not empty
if($_GET['image'] != "") {
// Then check if the file is valid
if(file_exists($path . $_GET['image'])) {
// If an image exists then display image
echo '<img src="'. $_GET['image'] . '" />;
}
}
?>
Below this script you can put all your thumbnails the way you want. Ofcourse, also for these thumbnails there are some automated options. But I strongly suggest you get a good look at the script above and some beginner PHP tutorials so you completely understand the example given. This still isn't the best method, but it's kicking you in the right direction.
if your imagegallery.php is in root of your domain, you can just add slash as a first char to links like this:
<img src="thumbnail1.jpg>
else you will have to write some php function which it returns BaseUrl of your web. Then it should looks like this:
<img src="thumbnail1.jpg>
maybe you can something like this,
Techincally, there is no thumbnail image, just a stretch version of the regular image
I don't understand which part you don't know how to do:
- the link part?
it should look like
<img src="thumbnail1.jpg>
- or the PHP part (the file called imagegallery.php)?