CGPDFDocument can't draw jpeg2000? - core-graphics

HI,guys.
I'm using this code to draw pdf,but i've compress the pdf's image to jpeg2000.so the cgpdfdocument can't decode the jpeg2000,just show noting but blank.how can i make it to decode the jpeg2000?
thanks.any advice will be gratefull.
CGPDFDocumentRef document;
CGPDFPageRef page;
CGRect box;
document = MyGetPDFDocumentRef (filename); // 1
page = CGPDFDocumentGetPage (document, pageNumber); // 2
CGContextDrawPDFPage (myContext, page); // 3
CGPDFDocumentRelease (document);

This is likely a bug in Apple's CoreGraphics library. Apple's engine definitely does support JPEG 2000, even though the decompression code is very slow, it certainly works.
There's even an open source example that shows how to decompress JPEG 2000 using ImageIO - however that will not help you much other than answering the question on JPEG 2000 compatibility.
I recommend submitting a radar with the faulty PDF to radar.apple.com.
However, don't get your hopes up that this will be fixed anytime soon. Over the years we reported countless rendering issues with the CoreGraphics PDF render engine as we used it in the commercial PSPDFKit SDK v1-v4. With last year's v5 release we finally finished and switched to our own rendering engine that improved on many of the problems that Apple's engine has, especially with more exotic files or compression formats. You're welcome to try our SDK and render engine and please report a bug to us as well if you find a file that renders in Adobe Acrobat but not our SDK - we're really good in terms of compatibility now and trusted by major brands such as Dropbox or IBM.

Related

Include ICC Colour Profile in PDF created with Objective-C iOS?

In my Objective-C iOS app I'm creating PDF files using the code:
UIGraphicsPDFRenderer* renderer = [[UIGraphicsPDFRenderer alloc] initWithBounds:pdfSize];
NSData* outputPdfData = [renderer PDFDataWithActions:^(UIGraphicsPDFRendererContext * _Nonnull context) {
[context beginPage];
// draw operations here
}];
The ultimate aim is to then send this PDF to an AirPrinter.
However, due to the printer hardware we're using it looks like it is going to be necessary to embed in to the PDF an ICC colour profile (possibly CMYK) to ensure accurate colour reproduction.
I've done such operations before in .Net but never in Objective-C and so far all of my web searching has been for nought.
Is it possible to embed ICC colour profiles in to the PDF context in Objective-C using the above approach, or if not is there another way to produce PDFs in Objective-C that does allow ICC profile embedding?
After a lot of searching I've concluded this isn't possible. Documentation is thin on the ground and what does exist usually refers to Mac OSX, not iOS.
ColorSync, as suggested by Moose, appears to be restricted to images and UI elements, and I can see no way of including it in PDF creation. Closing.
Maybe you could try to create a colorSync profile for the printer you use, and let the system correctly prepare you document for this printer, or any another one..
ColorSync is supported since OS9.3 on iOS Devices.

JPEG RAW images not displaying in Safari on MacOS Sierra or iOS 10

We've recently had some users of our app report that JPEG images aren't displaying properly since they updated to iOS 10.
We've looked into it and found that some JPEG images do work OK, and some don't. There are no errors logged anywhere.
The ones that don't work in our app also don't work in Safari on iOS 10. Not only that, but they also don't work in Safari on MacOS Sierra.
So we've checked the files themselves out and found that the files that don't work begin ÿØÿÛ, while the others that do work OK begin ÿØÿá.
Googling these signatures led us to this page: https://en.wikipedia.org/wiki/List_of_file_signatures
Here it states that the images that aren't working are JPEG Raw, as opposed to JFIF or Exif format JPEGs.
So the question is: Why does this no longer work, and what's the best solution to work around it? I don't want to have to re-encode the images because of the lossy nature of JPEGs. We also can't get the source of these images to change, unfortunately.
We've considered a solution for our app, but that won't solve the problem in Safari.
There's always the wonder of why have Apple removed support for this format?

How to view the code behind a PDF document in IOS

I have a PDF page that I've converted into a stream:
CGPDFContentStreamRef contentStream = CGPDFContentStreamCreateWithPage(pdfPage);
How can I view that stream as an NSString? I'd like to see the code that represents the PDF.
Thanks!
It's not as easy as that. A stream can be any binary data, there might be multiple chained compression formats used. See http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf (Page 23ff) for potential formats.
Your best option is CGPDFScanner other than re-implementing a PDF parser/lexer from scratch (We did that in the commercially available PSPDFKit SDK for iOS and Android - it's complicated.)

Hyperlinks for PDF in the iPhone

How to add/access hyperlinks (both internal and web page) in the PDF in iphone?
Sri
Not sure if you are asking this from a user or implementation perspective, I assume implementation as this is a programming Q/A site:
The PDF will more than likely be rasterized to an image for the phone, it will be up to the reader to extract the text/links and overlay these over the image to make them clickable.
I have seen this type of thing in flash readers/pagers where these link/hotspots are configured manually, obviously not an option for a generic PDF reader
This is the best that I have found on SO: Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?. Many links and helpful tips.

Can Adobe AIR display SVG?

I see that Adobe AIR uses WebKit as its render and I see that WebKit (at least the most current build) has some SVG support. Does this mean (and has anyone specifically tried) that an Adobe AIR application could render SVG on an HTML page?
On the offchance that it's helpful (and that you don't already know), Flex can embed SVG at runtime compile time, which effectively converts it to SWF format and embeds it as a resource.
[Embed(source="assets/frog.svg")]
[Bindable]
public var SvgAsset:Class;
More info at Adobe's embedding assets article.
If ActionScript 2: use the com.itechnica.svg (PathToArray) library to load SVGs at SWF runtime and display them (uses XML for SVG parsing):
Using SVG Path Data in Flash, Download button on the right pane.
If ActionScript 3: use the com.zavoo.svg (SvgPath) library to load SVGs at SWF runtime and display them (uses RegExp for SVG parsing):
Source code for SvgLoad and SvgDraw, Download button on the bottom-left.
No, according to the Adobe AIR Developer Center article What's new about HTML, HTML5, CSS, and JavaScript in AIR 2.5?.
SVG
Another feature that has received
a great deal of interest lately is
support for SVG. While present in
WebKit, the current version of Adobe
AIR does not support SVG.
The main reason for not including it
was runtime size concerns (adding it
would have increased the runtime size
by 15 to 20 percent). Initially, the
main pain-points regarding AIR were
the size of the runtime, integration
with the operating system and native
APIs, support for the tag and
new CSS properties, and JavaScript
performance. These priorities, coupled
with a trend toward reduced interest
in SVG graphics, led to SVG support
not being included in the current
version of Adobe AIR.
However, the renewed interest in rich
JavaScript applications powered by
HTML5 canvas and faster JavaScript
engines increased the number of
requests for scriptable vector
graphics via SVG. Thus, adding support
for SVG graphics may be considered for
the next version of AIR.
Adobe AIR can only support SVG once Adobe updates their version of WebKit (AIR's HTML rendering engine) and enables the SVG support within their version of WebKit. Might be a business decision not to (ie Flash).