CGContextDrawPDFPage renders white page for valid PDF - ios

I have an issue with PDF rendering using the CGContextDrawPDFPage function. I develop an iPad app (targeting iOS 7) that does very specific things with PDF, and I cannot use UIWebView so please don't suggest it. One of our customers reports a white page being rendered while every other PDF viewer renders the PDF just fine.
To make sure I don't have any dumb errors in my own code, I have taken Apple's ZoomingPDFViewer (https://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html), replaced the PDF they ship with the one from our customer, and started it: indeed a white page is being rendered in stead of the proper contents (a scan from a building blueprint.)
I am 100% certain is the not the loading, viewing or rendering code in the ZoomingPDFViewer example from Apple, because every other PDF file I try to view with the example renders just fine!
I'm trying to obtain permission to upload the PDF here, but I don't have it yet, so my question is: without access to the PDF that's being rendered wrongly, has anyone any idea on what this might be? Are there any limits in the PDF renderer that might cause a white page to be rendered?
Thanks in advance!
edit: The PDF is rendered perfectly in every other PDF viewer, including but not limited to the iPad email application (!), Safari on Mac OS X, Preview on Mac OS X, Acrobat Reader on Windows, FoxIt reader on Windows.
edit: converting the original PDF file (which was a pdf 1.3) to a pdf 1.5 using ghostscript on Linux solved the issue: the PDF is now properly displayed! I used the following commandline:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -sOutputFile="filename.pdf" "filename.pdf"

The iOS pdf rendering engine does not support JPEG2000 images. If your scanned image is such an image then it will not be displayed.

Related

ghostscript compression distorts graphics

I am writing a large document in LaTeX and generate most of my schematics using Inkscape. I store all Inkscape schematics as PDF and include them using the default latex figure environment.
Because the final result is quite large I then compress the document using ghostscript, using the following bash command:
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/printer -sOutputFile=${FNAME}_compressed.pdf $FNAME.pdf
$FNAME is the PDF file name. I noticed that the compressed PDF distorts some of the PDF graphics generated by Inkscape, mostly replacing solid black lines for dashed ones.
I uploaded a distortion example. The uncompressed original is on the right. Ghostscript distorted version on the left.
The distortion happens regardless of the dPDFSETTINGS flag. As far as I understand Ghostscript compression works by regenerating the PDF code so that it looks the same, but obviously this is not working correctly. However, the only images affected appear to be the Inkscape generated PDFs. Matplotlib generated ones appear to be fine.
Could you help me figure out, what is wrong here?
Thanks in advance

Vectorial PDF with xCode using Affinity Designer

I'm newbie to Affinity Designer and I'm trying to export some Affinity Designer's project to xCode as vectorial pictures in PDF format.
Initially everything was working fine but, after some attempts (I'm designing the launch screen so, after every export, I make some little adjustments then I re-export the PDF) xCode started giving troubles: sometimes picture doesn't appear in XIB, sometimes appear only some giant pixels and, in very luck times picture appears but very grainy.
I tried changing the pixel's size of the picture (is the only setting I see) but it doesn't change nothing so my questions are:
- what are the requirements for xCode's vectorial PDF (resolution or other settings)?
- is there a precise iter to follow in Affinity Designer to export vectorial and import them in xCode? (I can't find any tutorial about it)
Thank you!
EDIT This issue has been fixed some time ago.
I think there's something missing (or wrong... for this context at least) in Affinity Designer's exported PDF files. If you open them in Preview, rotate (and back), then re-save, the vectors will load properly in your app.

Pdf.js: print rendering in Safari & Chrome

I am generating a PDF using TCPDF and feeding the resulting base64 stream to pdf.js for printing. The display output appears as expected, but when I preview or print the document, some unexpected scaling takes place.
In TCPDF, I am importing an existing PDF and overlaying that with data that is generated on the fly. The imported PDF in the print output is being scaled to about 25% of the page while the dynamic data appears to be scaled properly.
Display output - http://i.stack.imgur.com/PPQPt.png
Print output - http://i.stack.imgur.com/Go1Wy.png
This happens in Safari and Chrome, but in Firefox the print output is rendered correctly.
Any advice on how to get Safari and Chrome to cooperate?

QuickPDF converting a PDF to an Image: letters move in eachother

Quick PDF has a feature to convert a PDF into an Image:
iNumPages := PDFLibrary.PageCount();
PDFLibrary.RenderDocumentToFile(300, 0, iNumPages, 0, 'H:\temp\quickpdf_testimage_6_new.bmp');
If this feature is executed the letters move (with some PDF sources) in each other. In the following there is a PDF and the resulting JPG:
PDF: http://www.baunetz.de/aip/2001/tunnel.pdf
Now there is a problem: in the resulting Image the Letters move in eachother.
Update:
I have cause of the Problem:
"
This PDF contains a font (OfficinaSans-Book) that is not embedded in the PDF so Quick PDF substitutes Arial instead which has thicker characters.
This is a common problem with PDF's and many PDF viewers. The best solution is to create the PDF with embedded fonts for any of the non standard fonts that are used in the PDF."
http://www.quickpdf.org/forum/topic2478_post10369.html#10369
Update 2:
The only PDF Engine so far that has no Problems with 'lettes moving in each other' is the foxit DLL.
I have cause of the Problem: " This PDF contains a font (OfficinaSans-Book) that is not embedded in the PDF so Quick PDF substitutes Arial instead which has thicker characters.
This is a common problem with PDF's and many PDF viewers. The best solution is to create the PDF with embedded fonts for any of the non standard fonts that are used in the PDF." http://www.quickpdf.org/forum/topic2478_post10369.html#10369
Edit:
A possible solution would be to use MultiMaster fonts if the font wasn't found on the system. Adobe uses this technique. But i haven't found a way to implement that with quickpdf.

Why Safari on iPad doesn't show large jpeg enclosed in IMG tag?

Last time I saw someone asks why Safari on iPad doesn't show some 1920x1440 jpeg with real size & I solved that puzzle. You have to use a progressive-encoded jpeg. However, I find another different problem.
Say, demo.jpg is a progressive-encoded jpeg with 2000x3000 & I upload it to my website. I then access it via url ...demo.jpg, Safari will show it with 2000x3000 size, perfect.
Now I make a most-simple html file named mypic.html. This html has only img tag with src=demo.jpg or src=demo.jpg width=2000 height=3000 inside body. Now I access it via url ...mypic.html. This time Safari show a very small icon of a question mark?
Does anybody know why the latter case fail?
The problem is about the memory available to Safari. The total amount of RAM is just 256MB, and Safari stops showing the image of much smaller size. You need to scale them down.

Resources