Whenever I try to insert an image into a PDF, the whole PDF file crashes. (Google Chrome says, 'Failed to load PDF document', and the network response is empty.)
I am using the dompdf plugin for cakephp, and the error is definitely not due to dompdf not finding the images. When the source attribute points to a non-existing image, it just shows a square rectangle. When, on the other hand, the path is correct, or I provide the source using the 'data:…;base64,…' notation, the whole PDF crashes.
I have increased the maximum resolution to 300dpi in Config/dompdf.php , but it still didn't work. Any ideas?
Related
I'm trying to create a tool to rasterise vector images—stored in PDF files—on macOS, but the resulting images contain artifacts around the edges of some shapes. Preview.app, on the other hand, always renders the PDF flawlessly, as shown in this example:
I've tried:
Loading the PDF document using PDFKit, and rendering the page using both draw(with:to:) and thumbnail(of:for:)
Loading the PDF document into an NSImage (which creates an NSPDFImageRep), and using cgImage(forProposedRect:context:hints:)
In both cases I get these aliasing-like artifacts as seen on the left-hand-side of the image above. The PDF file is out of my control, so can't be changed to fix any issues it might have. I'm currently trying to migrate away from Cairo (which renders correctly) to Apple's PDF rendering for performance reasons (PDFKit renders it much more quickly, albeit with these artifacts).
Is there anything I've missed which would fix the output?
So it looks like the issue was caused due to me rasterising PDFs on multiple threads (specifically my tool rasterises PDFs in multiple resolutions, so I thought why not simultaneously).
Performing the operations sequentially on the main thread instead fixed it. I thought that I had come up with a way to use it concurrently by initialising the CGContext manually (instead of using NSImage's lockFocus()/unlockFocus() and NSGraphicsContext.current), but alas, as I soon as I add a context.scaleBy (to generate the images at different sizes), it fails again.
So for now I'm just doing it on the main thread until another solution comes along.
I'm building a project in ASP/MVC, and I'm having an issue with some of my images. I pull them out of a database as bytecode, convert them into Base 64, then render them. This process works fine with about 90% of the images I have to upload, but for certain images for some reason, they render cut off, as here:
Unfortunately, this only seems to happen in Chrome/Firefox, so I have to assume it's an issue with rendering. In fact, here's the image as the base 64, you can view it by using it like a url in your browser, if security allows. Otherwise you can put it in html tags and try to view it that way. This will only render correctly on IE as far as I can tell.
http://pastebin.com/RYasvfj0
If I view this image, right click, then save it, the saved image will be correct:
I'm at a total loss here. It's A) Inconsistent that the images won't work correctly, but
B) Consistent at when in the image it gets cut off. It's always the same portion through the image that it ceases loading on FF/Chrome
Any ideas on what's triggering those browsers to fail, and how I can check for it?
e; The base 64 here is padded; it's generated by C# via Convert.ToBase64String
Kinda new to wordpress.. Creating my own theme. When I upload an image and put it in a post it comes out at 300x183 pixels but the original file I upload is 1800x1100 pixels. Wordpress alters my size when i upload it.This is what i get in the url on the post NDAppleProductMockUp-300x183.jpg.. It restricts the size of the image. When i go into the image properties within the post and click original nothing happens it stays at 300x183.. I have tried to work it out but can't Any suggestions guys..
Thanks
Unfortunately, WordPress does not resize the actual image that you upload. It creates 3 smaller versions of it, leaving the uploaded image untouched. I would suggest that you create all of your images at 1800x1100 before you upload them.
Another solution would be to link to the "big-sized" image when you "Insert into Post"... unfortunately, you would have to know the filename of the large image. I check the source code and this part of the media system does not appear to be pluggable.
Another option may be to check out this plugin:
http://wordpress.org/extend/plugins/nextgen-gallery/
This link here details how You can change what image size will be displayed
http://codex.wordpress.org/Function_Reference/add_image_size
also when u attach to post you can set the image size in the setting
THE SETTING is Before you attach the image!
you are trying to change an image that has already been attached (the attached image was in a mid or small size to begin with) so it is already at its original size.
We are having problems with Facebook not showing images, which we noticed from 17 May.
We have images tagged in og:image, and this is showing up as a blank white space in the object debugger. Clicking on this blank white image/space shows the actual image expected in a new browser window, there are no issues with viewing the image within or outside the network (we tested using different devices and proxies to simulate access from outside Singapore, which is our main audience). The image is 300x225, but the debugger also show the "image not big enough" warning.
Sample scenario (HTTP removed from some links):
URL in question: www.hungrygowhere.com/dining-guide/what-to-eat/5-family-friendly-restaurants-to-book-online-*aid-53763f00/
og:image meta on the page: <meta property="og:image" content="http://staticc04.insing.com/images/f3/e0/10/00/pc_300x225.jpg" />
Warning on the debugger page: "Provided og:image is not big enough. Please use an image that's at least 200x200 px. Image 'staticc04.insing.com/images/f3/e0/10/00/pc_300x225.jpg' will be used instead."
Noticeably the src attribute on the debugger is similar to this: fbexternal-a.akamaihd.net/safe_image.php?d=AQAfsdJpTPWk1IqW&url=http%3A%2F%2Fstaticc05.insing.com%2Fimages%2Fe2%2Fdb%2F10%2F00%2Fpc_300x225.jpg and going directly to this image via the browser shows a blank 1x1 gif. We tested using a 600x600 image (after seeing a post about maintaining aspect ratio) but it's the same: external.ak.fbcdn.net/safe_image.php?d=AQDZBb-0AZjyOp_B&url=http%3A%2F%2Fstaticc03.insing.com%2Fimages%2F57%2Fde%2F10%2F00%2Fstb_600x600.jpg
Our hypothesis is that safe_image.php is not accepting the image it retrieves, but we have no idea what or why this is happening.
We have a ticket open on the Facebook bugs support forum for this (developers.facebook.com/bugs/647132798635052) but no response after the initial round of clarifications, but we are hard pressed to find a solution.
There were no changes to our image storage solution over this timeframe. No rewrites or redirects, the image URLs are files by their own right.
Edited to add:
It is strictly safe_image.php that is choking on our image. See a screenshot from the object debugger: http://i.imgur.com/kl336l9.png
The image on the right is the same og:image, but since it's accessed directly by FB (not going through safe_image.php), it shows up.
We have been checking logs and we are returning HTTP status 206 to Facebook (we have been doing this for a while now) but this was changed to return 200 at all times. No change, we are still not getting any images.
I am finding problem in using dompdf with codeigniter, in rendering the image.
Actually my requirement is as follows:
User fills a given form.
He clicks ab button to print the form.
At the same time when he print the form, a pdf version of that
from is to be sent to user.
I am using dompdf for that. It works well, but the logo which is an image is not displayed in view and also in rendered pdf file.
I googled for that, and found that image path should be wrt server and not wrt application.
eg. my image path is /var/www/my_system/images/logo.png.
But it didn't visible. It shows fails to load URL.
I am using dompdf-0.5.2 version.
Please suggest.
Any help would be greatly appriciated.
Your issue appears to be related to the PHP memory limit. You could try increasing the memory limit to prevent issues in the future.
Some image operations can be costly in terms of system memory. dompdf has to do a lot more processing with PNG to support the full feature set. The KB size of the image isn't the determining factor because the memory footprint has more to do with the dimensions of the image.
FYI, it always helps debugging PHP issues to be able to see any errors thrown.