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.
Related
I'm using Apache FOP to generate a PDF through XML and XSL-FO. I have a cell in my generated PDF that I need to be able to scroll through if the content overflows it. XSL-FO has an overflow="scroll" feature, but based on my research on the topic it seems that Apache FOP does not support this option.
For example, here is a scrollable region in a PDF used by a large CAD company that I need to replicate:
Is there any way to enable this feature in Apache FOP? Is it possible to enable it in the source code (I haven't been able to find a way to do so)? Any other ways to tackle this issue?
No, it isn't possible.
From the FO perspective:
In the XSL-FO Recommendation the scroll value for the property overflow comes from the corresponding CSS2 definition, which includes this clarification:
When this value is specified and the target medium is "print", overflowing content should be printed.
As the PDF output is a print-oriented medium, I read this as a confirmation that FOP is correct in printing the overflowing content.
From the PDF perspective:
In the PDF Reference 6th edition, a search for the word "scroll" returns results referring either to the scrolling bars in the user interface or in interactive forms (text fields, list boxes, combo boxes).
There is not, or at least I could not find it, a "static text object, but with scrolling bars" feature (which is probably sensible for a print-oriented format), so FOP cannot create it in the PDF output file, not even modifying the source code.
A second look at your comment and the screenshot you included made me think it could be an example of the 3D Artwork feature of the PDF format, a feature I didn't know of before (and I still know nothing besides its name). According to the reference:
Specific views of 3D artwork can be specified, including a default view that is displayed initially and other views that can be selected. Views can have names that can be presented in a user interface.
So, I think your screenshot shows the different views associated to a 3D object; it is not a general-purpose feature that could be used to provide scrollable text.
Well, it could be possible ...
It is possible but as far as I know not with Apache FOP. Without seeing the PDF in question and guessing from the screen shot, it looks like a Flash widget inserted into the PDF. This in PDF terms is a RichMedia annotation (requires PDF version 1.7 with extensions) in which you can insert the Flash widget as well as other controlling files (like XML, other images to display, etc.) and relate them together.
AFAIK, only RenderX XEP (whom I work for) supports such RichMedia annotations inserted into PDF via XSL FO through the rx:rich-media-object extension documented here: http://www.renderx.com/reference.html#Rich Media
I believe, the only viewer that supports PDF with RichMedia annotations is Adobe Reader so it is required to view such a file. Here is a sample that includes a few interactive flash widgets, some interactive charts all within a few page PDF that was generated long ago. NOTE: I am sure some of the links in the document do not go anywhere, it was for a trade show many years ago. Remember, you would need to download this file and view in Adobe Reader and have flash player installed to see it function.
http://www.cloudformatter.com/Resources/Samples/RichMedia.pdf
You cannot use common PDF browser-based viewers like Chrome or Firefox as they do not support this type of annotation.
A screenshot of page one here shows an interactive, scrolling widget. Page 4 contains a widget similar to what you show in your example.
Page 4 scrolling widget very similar to your request:
The widget on the last page is created using a scroller SWF that takes parameters that are the images and setup/configuration files that are XML. The RenderX extension object takes these as parameters and embeds all of them in the document for the interactive flash widget so that it is totally self-contai9ned in the PDF. The XSL FO to do this is:
<rx:rich-media-object name="Sample HTML Widget" scaling="non-uniform" width="611.92pt"
height="74.99pt" content-width="scale-to-fit" src="url('rx-scroller\dockmenu.swf')"
transparency="true" activate-condition="page_visible">
<rx:flash-var name="setupXML" value="rx-dock-settings.xml"/>
<rx:flash-var name="contentXML" value="rx-dock-contents.xml"/>
<rx:rich-media-resource name="rx-dock-settings.xml"
src="url('rx-scroller\rx-dock-settings.xml')"/>
<rx:rich-media-resource name="rx-dock-contents.xml"
src="url('rx-scroller\rx-dock-contents.xml')"/>
<rx:rich-media-resource name="style.css" src="url('rx-scroller\css\style.css')"/>
<rx:rich-media-resource name="customer1.png" src="url('rx-scroller\images\customer1.png')"/>
<rx:rich-media-resource name="customer2.png" src="url('rx-scroller\images\customer2.png')"/>
<rx:rich-media-resource name="customer3.png" src="url('rx-scroller\images\customer3.png')"/>
<rx:rich-media-resource name="customer4.png" src="url('rx-scroller\images\customer4.png')"/>
<rx:rich-media-resource name="customer5.png" src="url('rx-scroller\images\customer5.png')"/>
<rx:rich-media-resource name="customer6.png" src="url('rx-scroller\images\customer6.png')"/>
</rx:rich-media-object>
And note that many things that are in the flash would work, like links and such. It is just a pure, interactive flash inserted into PDF as the container.
Indeed it looks like this is not possible to achieve through FOP.
Continuing to dig around for a few days, however, I did find a clever post-processing alternative that is also free, essentially embedding a PDF inside of another PDF using the LaTeX animate package.
A drawback to this method is that it is not possible to embed links inside of the scrollable region, which is a major issue for me. But the method does enable inserting a scrollable region inside of an existing PDF and got me very close to what I was trying to achieve.
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.)
We have an institutional logo, one design for color, and a different design for bi-level (B&W) renders. I have combined these two designs into one Encapsulated PostScript (EPS) file so that the proper design is selected at render-time depending on the color capabilities of the device.
Unfortunately, this functionality doesn't transfer when the graphic is translated to PDF. Is it possible to create a single PDF document that can display the color version of the logo when printed on a full-color device, and use the proper bi-level logo when printed on a B&W printer? (Our communications department insists that our logo should not be gray-scaled.)
I spent the weekend reading the PDF Reference, but I could not find a way to test render device capabilities from within the document, or conditionally execute sets of drawing primitives. Did I miss something?
Addendum:
The PostScript code that implements this looks like this:
systemdict /currentpagedevice known % PostScript Level 2 test
{ currentpagedevice
/ProcessColorModel get
/DeviceGray ne % pushes TRUE on stack if color
}
{ systemdict /processcolors known } % PostScript Level 1 punt
ifelse
{ color_logo } % True: Draw full-color design
{ bilevel_logo } % False: Draw B&W design
ifelse
I'm looking for a PDF equivalent, if such a thing is possible.
I don't know of any proven solution to your problem, but you might want to try and use JavaScript™ for Acrobat® API.
Using JavaScript, it might be possible to change background images of buttons before document is printed. Or to change visibility of Optional Content Groups.
The following structures in the API might be of some interest to you:
Doc/WillPrint event
PrintParams object
Annotation object
OCG and it's properties
You can embed Javascript in a PDF using Acrobat Professional and a number of 3rd-party tools and libraries.
Please note, that most probably no PDF viewer except Adobe Reader supports full JavaScript API.
EDIT:
Another possibility is to embed Postscript directly in your PDF. There are PostScript XObjects for that.
Unfortunately, such objects might be unsupported or not fully supported in most viewers. Adobe Community forum has a thread about embedding of Postscript in PDF.
From the docs for quicklook:
"The consumer portion of Quick Look
has three components: a document
reader (consisting of a custom view
and panel), display bundles for that
reader, and an SPI to enable
communication with the client. Each of
these components has a specific role
to play in support of the consumer:
Document reader—Quick Look implements
a view (NSView) and panel (NSPanel)
customized for displaying document
previews. Along with the preview
content, the view might include (at
the client’s option) controls for
manipulating the preview, such as
page-forward, page-backward, start
playing, rewind, and text-search. A
client application can embed this view
in its user interface if it chooses.
The Quick Look panel contains a Quick
Look view and various controls that
let the user take some action with the
preview, such making the preview image
full-screen or starting a slideshow."
I have been poring through all the docs and examples for quicklook and I don't see either:
A definition of any sort of "Document reader" component or way to access it.
Any sort of SPI as such that would show how to consumer quicklook
Any direct access to the NSView used by quicklook to display previews.
All I want to to do as the docs say: embed quicklook's view in my own hierarchy rather than in the Panel. The panel of course has abundant documentation. Has anyone successfully used Quicklook in this manner before?
The class you are looking for is QLPreviewView, part of Quartz.framework. It's a public class (introduced in Lion, I believe). Unfortunately, the docs team apparently hasn't yet released its documentation, which is probably why you couldn't find it. The official docs are now available.
The short, short version is that you create it the way you would any other view, and set its previewItem to an id <QLPreviewItem> that you supply. The <QLPreviewItem> protocol is documented. E.g.
QLPreviewView *pv = [[QLPreviewView alloc] initWithFrame:frame
style:QLPreviewViewStyleNormal];
[pv setPreviewItem:item];
[myView addSubview:pv];
[pv release];
That's the basic concept, YMMV.
Its operation is thoroughly covered in the 2011 WWDC session "System-wide Previews on Mac OS X and iOS" (or something to that effect). You should be able to get the video if you are a paid member of either the Mac OS X or iOS developer programs.
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.