swift open urls from pdf file - swift

I'm working with pdf files that have urls inside it, and it's presented like images, I want the pdf to be presented like html file, so when the user clicks on a url inside the document it opens the url using safari
I'm using this library to read pdf files
https://github.com/Alua-Kinzhebayeva/iOS-PDF-Reader
and I have no problem to migrate to another library if it supports what I need

From a quick look at that library, it appears it is rendering each page as an image and then displaying it. It would probably be pretty tough to use that library to allow clickable links.
I don't have any experience with 3rd party solutions but theres a couple ways to do it provided by Apple.
You could show the pdf in a WKWebView or a QLPreviewController. Both have delegate methods that are called when a link is clicked.

Related

How to provide one-touch access to a PDF file in the cloud with rich features like annotation?

I need to be able to download a PDF file from a location on the Internet and then open it (just the file, not to a specific page) in an app like Goodreader or even iBooks.
What I originally thought was that I would put an icon on my users' home page that launches a PDF file in an app, similar to how in Safari you can "Add To Home Page" and add a link onto the Home Page. The idea would be to have that functionality but with an, e.g., ibooks:// link rather than an http:// and it would open the pdf being linked to there within iBooks.
I am able to launch Safari to view a PDF using the Add To Home Page function to put an icon on the Home Page pointing to a PDF at a certain URL, so I am wondering if using, e.g. a Scheme definition I can pull it off.
So my solutions so for are:
1) Create a link to the PDF to open in Safari using "Add To Home Page" (offers zero functionality, including the hard requirement of being able to annotate the PDF)
2) Employ a specific App's Custom URL Scheme Definiton with the iPhone Configuration Utility's "Web Clips" create something to the effect of ibooks://www.pdf.com/document.pdf (i dont think this works)
3) Write a custom app and figure out how to do the annotating part myself (Did this using FastPDFKit but it does not include anything for annotating which is really key)
I believe if you put a g infront of the URL when adding to home screen, it will open with GoodReader when launched.

What is the most elegant way to view a multipage PDF in iOS application?

I am stuck in a predicament whereby I hope someone can help me.
I am consuming a web service that returns a multi page PDF document as a Base64 payload. I want to be able to view the PDF on a page by page basis. For example I get the following string back in a long Base 64 encoded form within image tags :
<image>JVBERi0xLjMNCiXi48/TDQoxIDAgb2JqDQo8PA0KL01vZER........</image>
I am not wanting to use a UIWebView to view the fax but a simple very basic PDF viewer with pagination. I know there are some libraries like Fast PDF Kit but that would not work because they show the logo and the license is a little pricey.
I am a PDF newbie so if someone can show by a small example I would truly appreciate that.
I'm not sure why you don't want to use UIWebView since it probably does everything you need. PDF parsing guide from Apple will show you how to implement this by hand:
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html

open ms doc,docx or image file in browser in c#

I have developed the asp.net mvc application. my one form have the file upload control. so in details view i want to implement the facility to view the uploaded document in browser itself. it should not ask for download and should not open MS office instance to open document. its a user req. It should opens in view mode in browser itself. what code i have to do ? I am using C# as language.
It is not straight forward. For images you can use <img>tag and link to the location in server where you saved the uploaded image. That should work.
However ASFAIK showing the doc/docx things in web page itself is not possible. You will have to employ some third party control to achieve that. Search google to find such controls. May come at a cost.

How can I simply add a downloadable PDF file to my page?

I want to add a pdf and word format of my resume to my portfolio page and make it downloadable. Does anyone have some simple script?
Add a link to the file and let the browser handle the download.
You may be over-complicating the problem. It's possible to use a href pointing to the location of the .pdf or .doc file, when a user clicks on this in their browser, generally they will be asked if they would like to save or open the file, depending on their OS/configuration.
If this is still confusing, leave a comment and I'll explain anything you don't get.
Create the PDF. Upload it. Add a link.
Save yourself 30 minutes tossing around with PDFGEN code.
You will want to issue or employ the Content-Disposition HTTP header to force the download otherwise some browsers may recognize the common file extensions and try to automatically open the file contents. It will feel more professional if the link actually downloads the file instead of launching an app - important for a resume I think.
Content-Disposition must be generated within the page from the server side as far as I know.
Option:
Upload your resume to Google Docs.
Add a link to the file on your portfolio page just as I do in the menu of my blog:
Use Google Docs Viewer passing to it the URL of the PDF as you can see in this link.

In iphone development, is it possible to evaluate a javascript string using a webView in which a PDF is loaded?

I have loaded a PDF into UIWebView. Now i want to search for strings in that pdf. So I used a string which contains JS steps(used to highlight that specific string) and evaluated it with the webView object like this. But no result was obtained .It was as if nothing had been done.
Dont the JS evaluation work on a pdf loaded into a webView? Is there anyother way to search for a string in a PDF loaded into webView?
Even if you could evaluate JS against a webview that is currently displaying a pdf, the pdf render has no exposed or documented APIs. If you have code that works on HTML then it is not working because the PDF is not exposing an HTML like dom. If you have code that works in the acrobat plugin on a desktop then it won't work because the phone uses a derivative of Apple's Webkit PDF plugin which does not export the same API as Acrobat (as far as I know it exports no API, and if it does it is undocumented). In any event, regardless of why you think your code should work, it won't.
If you want to find a string in a pdf you are going to need to write code to parse the PDF and find that string, and even then you will not be able to highlight the specific string in the webview based renderer.
If you want this sort of functionality you should should use Quartz to directly render your PDFs onto views. Apple provides documentation for how to do that.