how to register the app to open the pdf file in my app in ipad

i want to open the pdf file in my app from pdf page, but i am not getting any option of opening the pdf in my app.

this my info.plist file

 <key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
    <key>CFBundleTypeName</key>
    <string>PDF</string>
    <key>CFBundleTypeRole</key>
            <string>Viewer</string>     
    <key>CFBundleTypeIconFiles</key>
    <string>Icon.png</string>
    <key>LSItemContentTypes</key>
    <string>com.neosofttech.pdf</string>
    <key>LSHandlerRank</key>
    <string>Owner</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
   <array>
   <dict>
    <key>UTTypeConformsTo</key>
        <array>

<string>public.pdf</string>       
         </array>
    <key>UTTypeDescription</key>
    <string>PDFReader File</string>
    <key>UTTypeIdentifier</key>
    <string>com.neosofttech.pdf</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <string>pdf</string>

    </dict>
</dict>

pls tell me where i am wrong in this, how can i open the pdf file in my app.


I'm assuming that you're trying to open an attachment from within Mail based on your plist here. Since you don't own the PDF file type you can't declare it as an exported type. You only need to declare it as a supported document type.

For example:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PDF</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
</array>

You can find a list of all of the system supplied content types here or in UTCoreTypes.h.

When someone does open a PDF file and chooses your application that file will be copied to an Inbox subdirectory of your Documents folder in your app sandbox. Your app will then be opened and within your app delegate's application:didFinishLaunchingWithOptions: your launchOptions dictionary will contain a UIApplicationLaunchOptionsURLKey key specifying the URL of the file within your sandbox that you can then work with.


You can't do what you're trying to do unless you do the following:

  • Register a custom url with the system
  • Call that custom url from within a hyperlink inside the PDF
  • Generate a PDF with clickable links

So what this means is that you register a custom url handler in your info.plist. For example, let's say you create a custom url handler with the form coolapp://. Now, inside of your document from which you generate the PDF, when you create a hyperlink, have it use your custom URL, for example coolapp://filedetails?pdfurl=mywebsite.com/path/to/pdffile.pdf&pageno=5. You then have to parse this in -application:handleOpenURL:. Download the file specified in the pdfurl field and then jump to the page specified in pageno.

Keep in mind that this assumes you are creating the PDF in question yourself. If you do not control the PDF content creation process, you cannot do what you are wanting to do. There is no way to open your app from an arbitrary PDF. It has to be done using a custom URL.

Let me know if you need clarification.


Insert code below to info.plist

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>"*"</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>Unknown</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
        </array>
    </dict>
</array>

Old post - but I landed on here also looking for a way to pass a PDF to my App.

The plist depicted by Ashley Clark help me to register my App as an App that can take a PDF file as a parameter. +1 for him on that one :-)

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PDF</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
</array>

However, to fully implement this, I used the following method in my AppDelegate.m file:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {

    NSLog(@"sourceApplication: %@", sourceApplication);
    NSLog(@"url: %@", url);

The above runs when the App is opened as I was running Safari and had a PDF that I wanted to share from there.

Above, I can determine which App passed my App the PDF and the URL to it's location.

When run, it outputs the following:

sourceApplication: com.apple.mobilesafari

url: file:///Users/me/Library/Developer/CoreSimulator/Devices/C395439F-7A0D-434F-8D78-D4615DB643E1/data/Containers/Data/Application/E3B181BC-6075-4F2C-923D-2ECC642DA555/Documents/Inbox/pdf-5.pdf

I can then use the URL to open the PDF and do whatever I want with it in my App.