ImageMagick convert (PDF to JPG) returns white image with black stripes at the top - pdf

I've encountered some issues in converting a multipage PDF files to JPG with ImageMagick.
The process returns a white page with black stripes at the top. It seems like the text has been 'compressed' and written at the very top of the page. I experience this behavior only with a given PDF file (the others work fine). I am running ImageMagick-6.9.8-Q16 on Windows. I also tried with ImageMagick-7.0.5 but I obtain the same result. I also tried using directly Ghostscript (9.21) and the output is the same. I think there must be something wrong with the PDF at this point.
Here's the pdf I am trying to convert to image and here is the result I obtain for the first page of the PDF. Subsequent ones are also like this.
Any clues on what's going on? Any suggestion on how to make it work?

Related

create white margin around pdf document without shrinking

I've got the following problem:
I want to print a PDF file as a booklet, using Adobe Acrobat Reader (in a copy shop, they got no better printing software). Unfortunately, Adobe shrinks my file down to the printable area. Instead I want to have it printet 50%(cause it'a a booklet, every page shrinked down by half) the original size, without shrinking any further, the margins simply cut off (just the egde of some pics etc, not important, the size matters)
My idea was, to use a software to create a white margin around every page, covering the stuff in the not-printable-area. Then adobe would not shrink anything down.
Does anyone know a tool for my problem? I couldnt find one. (running on either Windows or Ubuntu)
I would prefer a command line tool, cause I got a bunch of files to print.
Or is there a way to tell adobe Reader to not shrink anything (I know it works with normal printing, just couldnt figure it out with booklet printing)
Or are there any other ideas out there?
thanks in advance
Nevermind, i found a solution:
I created a PDF template with a white margin, transparent in the middle.
Using 'pdftk' I can easily set my original file als background of my template.
Done.

PDF with OCR text visible, how to hide it from existing PDF

I have several PDF files that have been OCR-processed (not by me). They contain both the scanned image and the OCR text. They seem to work fine in some viewers (iPhone/iPad), but not in others (Preview.app on macOS) which makes them somewhat awkward to read.
From googling around, it seems that the text & image may be layered incorrectly or there is a problem with the fonts used? I'm not even sure I'm using the correct vocabulary, as most hits I get are worthless.
Is it possible to use ghostscript or something to batch-fix these files?
Example of "bad" rendering:
Its impossible to say what's wrong with the PDF file (or viewer) without seeing the PDF file, which alse makes it hard to propose solutions!
You could certainly run the file through Ghostscript to the pdfwrite device, and use the -dFILTERTEXT switch to not process the text. The resulting document would therefore not contain the offending text, but would still contain the image.
Of course, this would then not be possible to search or highlight.
You could instead use -dFILTERIMAGE which would remove the original image leaving the text behind. But then anything in the original document which was not text would now be missing.
The usual 'best practice' is to have the text drawn in rendering mode 3, which makes no marks. This allows you to see the original image without the OCR'ed text interfering. Its possible that the viewer you are using is not honouring the text rendering mode, which would be a (fairly serious) bug in the viewer. The most recent versions of MacOS seems to have some nasty bugs in the Quartz PDF rendering engine.
The other way to do this is to draw the text first, then put the original image on top of it, but that's hard to get wrong, I suspect its more likely the text rendering mode.
EDIT
The PDF file first draws the text, then draws the image on top of the text. The underlying text should not appear. mkl is quite correct in his comment.
The correct way to fix this is to fix the consumer which is rendering it incorrectly. As I mentioned above the latest version of Quartz seems to have some fairly serious bugs, you might choose to raise this as a bug with Apple.
The only other solution would be to run this through something which will remove the text. Ghostscript can do this but there are implications; firstly it will no longer be possible to search/copy/paste text from the document. Secondly you would need to run quite a complex command line in order to prevent the decompressed JPX images being recompressed as JPEG, which would probably result in compromised quality. Finally the resulting file size would be larger.

Converting pdf to vector image

I'm trying to use pdf content (mathematics) in my webpage. I basically want to convert the pdf to some vector image. Converting the pdf to swf does the job very well, but as flash isn't supported on every platform, I'm trying to find another solution.
I read about svg, but as those pdf's contain a lot of mathematics, the result of the converters I found is really ugly and incorrect.
I've also thought about retyping the latex, and displaying it using mathjax, in some way this is the best solution, but also very time consuming.
The only thing I want is to convert it to a nice vector image, I don't want to change the content, or anything else. Besides converting to swf or retyping it, is there any other solution ?
Edit:
this is svg output
and here original pdf
The only solution I could find is illustrator.
Just open the pdf, save as svg, and choose to embed all used glyphs.
Result is perfect:
https://dl.dropboxusercontent.com/u/58922976/Sol-10.1.svg
what about using flash + raster image in case of platform without flash, if flash mostly works for you?
Your PDF is a little difficult for reasons that are probably not apparent to you.
The core problem with it is that some of the graphics in the document are actually drawn using custom glyphs. You can see this if you copy and paste the text out of Acrobat. There are a variety of unusual characters in there that don't seem to serve any useful purpose. That's those squares at the bottom of your SVG with EEs and FFs in them.
However these characters are actually custom glyphs for things like the braces around the matrices at the bottom of the page. So they are both fairly important and also very specific to this document.
I tried ABCpdf .NET to convert your PDF to SVG. It worked fine apart from these custom glyphs at the bottom. The output was about 90KB. It looked very similar to your inkscape SVG output but just a bit smaller (the inkscape one is 160KB).
The only way to get rid of these non-Unicode glyphs is to vectorize the text. I did this using ABCpdf and the output looked fine in SVG. But... vectorized text is big and SVG isn't a particularly efficient medium. The output was about 1MB! Zipped it goes down to half that but it's still no-where near as efficient as the original PDF.
The problems I am seeing here are going to be universal whatever format you use. These custom characters are always going to be problematic whether you output to SVG, SWF, HTML canvas, VML or indeed any vector format.
So what would I suggest? Well the obvious vector format that is widely used on the web is... PDF!
I know it's not quite what you're looking for but I think this is the realistic solution given the constraints above. :-)

How to convert PDF to an Image without text

I would like to know if its possible to convert a PDF to and image without fonts. My goal is to have only the image without text ?
And if yes, can I do it with ImageMagick/GhostScript ?
Here an example
The image final http://crocodoc_public.s3.amazonaws.com/8b8aa154-45e3-41f9-a465-628e1b2e955d/images/page-001.png
and the original PDF http://crocodoc.com/demo/efwpa (page 2) We can see that the text are on overlay over the image, what I want is to do the same.
So if I got you right, what you want is to remove some text from your PDF (not fonts), and you want to do it programmatically. I suspect you know already that this will only possible if the text is placed on some kind of separate layer in your PDF files. You can try to utilize iText for that. Beware, this will mean you will have to invest some days of learning how to use that library.
I too am the lookout for something like that.
While playing with imagemagick I tried this a command and got some unexpected results.
convert -input.pdf -blur 0x0 output.jpg
this removes the text layers from the pdfs I tried.
I cannot guarantee that this will work for you and if this the right way to achieve, but you may try.
You can do that with Adobe Acrobat. Select the text with the touch up tool and delete it. I don't think you can do that with Ghostscript. You could consider editing the PDF by hand (qpdf helps).

image colors in pdf files in vb.net

I'm creating a program to generate PDF files in VB.Net.
Everything is working fine except that the image is being displayed with a blue background while the image provided doesn't have any.
Following are the lines of code being used:
sColor = IIf(mvarEncodeASCII85, ToASCII85(ImgColor),
(System.Text.Encoding.GetEncoding(1252).GetString(ImgColor)))
What am I doing wrong?
There is not alot of details, but my first thougt is that it is .png-files or .gif-files.
Am I correct? In that case it may be an issue with adobe acrobat handling the transparent backgrounds.
As I said it's hard to say exactly without any further details.