Xcode PDFKit form automatic calculation - ios

This may not be possible, but after searching for quite a while I thought I would ask the question to either point me in the right direction or confirm it's not possible!
I have iOS app (Xcode swift) that displays pdf documents using PDFKit
I have several PDF forms created in acrobat that have simply calculations which update automatically as numbers are entered or checkboxes ticked i.e. adding numbers together, totalling the number of checkboxes ticked.
Whilst each form has only simply calculations, each has a different number of input fields.
Is it possible in PDFKit (or another method) to display these PDF forms in an iOS app and have them perform the calculations without having to re-write in Xcode the calculation per form, i.e. basically make use of the embedded javascript that is part of the PDF form?
At present, when I display the form, while I can edit the the editable textfields, the calculation doesn't occur.
Appreciate any help

I've discussed this at WWDC 2017 when Apple introduced PDFKit for iOS.
Their answer is that JavaScript is not a feature that they are planning to support. This is consistent with the level of support in Apple Preview on macOS and also Safari on iOS/macOS - none.
3rd-party PDF SDKs often also include JavaScript implementations. The spec is quite complex, so it's unlikely that you find a product implementing all of the 894 pages (including things like the Japanese Emperor calendar).
PSPDFKit supports the common JavaScript API necessary for most forms to validate correctly. An easy way to check if your forms are supported is trying it in PDF Viewer (free, ad-free app for iOS and Android)

Related

iOS create PDF invoice

I want to create a PDF invoice inside my iOS App (either in Objective-C or Swift).
My main problem is that the invoice might have several pages, which is very difficult to realize with the existing APIs from Apple (CoreGraphics, Quartz 2D, etc).
By now, I already have a barely working solution:
I created a HTML template which is the basic structure for the invoice
The template is filled with data using GRMustache
I load the generated HTML file into a UIWebView and save it as PDF (I used NDHTMLtoPDF to do this)
So far, so good.
The problem with this solution is that page breaks don't work properly.
There are some tables and images and the page break often cut's off tables or images.
I have tried to use the page-break-inside: avoid; css property for the images and the tables but UIWebView seems to ignore them completely...
My question is:
Do you know how to fix the page break problem?
Can you recommend another solution to create PDFs on iOS?
Should I design the invoice in Storyboard and generate a PDF from the UIView? What about the page breaks here?
I would prefer to have a template (e.g. HTML), fill it with data and save it as PDF, rather than doing everything in code.
I actually wrote a PDF reporting component myself with presumably similar requirements:
templating is done via HTML / CSS
Static Header / Footer on each page
You can achieve this with UIPrintPageRenderer and UIViewPrintFormatter APIs, with the downside of probably getting your app rejected in the app store review, since you're using private Apple APIs. So this approach might only be viable in an academic setting or if your developing in-house apps.
There are some tutorials on how to do this which I'm not going to repeat, but for me these resources were quite useful:
http://www.fromdev.com/2014/06/how-to-create-a4-size-pdf-file-in-ios.html
http://www.labs.saachitech.com/2012/10/23/pdf-generation-using-uiprintpagerenderer/

PDF4NET pdf's not showing the bound content when viewed on iOS default pdf reader

I am using Version 4.4.1.0 of O2S.Components.PDF4NET
I am using this in an MVC project to run through a series of 6 views and fill an object with the data required for the PDF.
When the PDF is bound and emailed in the last step it works great. all except for when it is viewed by default PDF reader on iOS devices.
My company purchased this product on the cheaper plan so the 90 support is over and I cannot access any sort of forums from there site.
I read a similar issue regarding a button not being displayed on iOS but there was no resolution other then to email the company.
I hope that there is a viable solution as I would prefer not to have to cut my losses and change to a different product over something as short sighted as not supporting/testing against one of the more common platforms people use to consume media.
I'm not sure what you mean by 'bound content' but I assume you are talking about form fields.
Forms fields and annotations are not displayed by the CGPDF API in iOS, only the main page content is displayed. It is not a limitation of PDF4NET, it is a limitation of the iOS PDF display engine. The workaround is to flatten the form fields thus making them part of the page content.
If this is not your situation, please send a mail to support and they will help you.
Disclaimer: I work for the company that develops PDF4NET.

How iOS Google Now can show different card template

I wanted to know the technology decision behind the iOS Google app.
As we can see, in the app's Google Now feature it renders many different card templates for different scenarios, and those templates seems to be very flexible based on server inputs.
I was wondering if this is implemented all based on HTML5? or they just have many templates built in and render them locally? I'd vote for the HTML5 route but not sure if this still involved some native code to make it more responsive?
Thanks!
As we (well, most of the community) are not Google employees we can't tell you what they really did, but I'd say that it is possible to do this dynamically in the app.
We did develop something similar that responds to definitions sent by the server and transforms them to custom designed forms following basic rules.
Google reuses the design of those cards for different plattforms, the easiest solution should be showing some WebView and using HTML5.
I agree with Kevin, as this answer is entirely based on personal opinion, too.
The way I would go is to create a card class which will load some JSON data and format it with HTML and CSS. Looking at each card it would be hell to format things that way natively. I mean, attributed strings is not the way to go. Too much logic for deciding which card get a bigger text or a picture.
Additionally, the top header is most likely "localized" as well, so you get the location and load a localized image. But that is Google by nature.

How to implement an interactive PDF in iOS

Here im hitting my head againt the wall.
My client provided a pdf with buttons(just like buttons,when user tap on button,it will load next page and previous page etc.).
This buttons will work only when we open it in adobe reader.
I tried the QLpreviewview,quickview but it is not working,all what i can do is just to load the pdf in the webview.
Can anyone please help me in how to load an interactive pdf in iOS.
Thanks in advance.
Have a look at PSPDFKit, it is the most advanced framework I've found for PDFs in iOS. They have an impressive list of customers as well.
It is a bit pricy though, but you have the option to get the Source Code too if you need to modify anything. Could be worth it if your client need that kind of performance and other features as well.
(I am not in any way affiliated with PSPDFKit)
The limitations are due to the capabilities (or non-capabilities) of the PDF viewer used.
Currently the leading PDF viewer on iDevices is PDFExpert by Readdle. Adobe Reader for iDevices is weaker, but can deal to some extent with form elements.
For page navigation etc. you might use links instead of button fields (as far as you can live with the capabilities of links, and not use JavaScript). Links are said to be handled properly with many PDF viewers.
You may have to require certain PDF viewers on instructional level, because you don't have control over the viewer used by the actual user. And, as you noticed, many PDF viewers are simply too dumb do deal with active elements.
Another approach would be looking at PDF-to-HTML5 converters, and serve HTML5 from a server.

Is it possible to load interactive elements into an iOS app?

Does anyone have any ideas how I could package an external interactive slide that could be dynamically loaded by an iOS app? Is it at all possible?
e.g. Imagine having a presentation app on an iPad. There is a set of interactive slides held on the web somewhere, let's say they contain draggable elements.
Can I load one of these slide objects into the app and interact with it? If so, what format would the slide object be?
Thanks,
Mark
Technically it's possible to dynamically load bundles (NSBundle) components in an app. These bundles could even contain executable code, though AppStore guidelines prohibit use of dynamically loaded NSBundles in this way for security reasons.
Additionally you could just use a UIWebView to display some 'slides' on a webpage, though it will be very hard to make the app behave as if it's the same as the native slides - perhaps even impossible (due to how rendering of webpages work compared to native controls, for example).
Ok so lets say you have these "external interactive slides" on a web server somehow. Since you are not saying they are of a certain type (like powerpoint or such) I will just assume that these slides are of some rare format that is probably not supported by any existing apps or the Safari browser.
Then the answer to your question would be: Write your own iOS-app that can read, present and edit these slides. What format are they? Well it doesn't matter. Write an app that can download the slide data from the data and parse it, and present it on the phone.
Then let the user interact with it, and perhaps make the app upload the changes to the server.
You can do anything you like in your app, there are no limits. You just have to write the code for it. If there was some kind of standardised format, lets say you wanted your app to show powerpoint presentations, then you would have 3 choices. Use someone elseĀ“s app, or write your own app with a parser for the powerpoint files or make your own app that use some code that someone else wrote to do it (a third part library that you include in your app)
In your specific case, I can not tell if there are any third part librarys to interact with your slides, but my guess is that you will need to do most of it on your own. You could start with looking at how the web services that interact with the slides online works, and if you can interact with them from an iOS-app that you make yourself.
There is nothing stopping you from creating an app, read the slide data into the app, present it in any way you like, let the user change it, save it in your app, or upload the changes to a server. It's all up to you =)
Good luck!

Resources