Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading Adobe Illustrator(.ai) file

Is it possible to load .ai files and open them programmatically?

This is what I have tried:

- (IBAction)openDocument:(id)sender
{
    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    [previewController setDataSource:self];
    [previewController setDelegate:self];
    [self presentModalViewController:previewController animated:YES];
}

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
    return 1;
}

- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
    return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];
}

But the output is like this:

enter image description here

like image 683
Manu Avatar asked May 23 '13 12:05

Manu


People also ask

Why is my AI file not opening?

One potential issue is that your Illustrator file may be corrupted. If you're unable to open the file, and you've tried repairing it using the software's built-in options, your best bet may be to try reinstalling Illustrator. If that doesn't work, you may need to find a new copy of the software.

What program do I need to open an AI file?

While Adobe Illustrator is a great vector graphics editor utilized by many artists, it saves files in a proprietary format. The AI file type that Adobe Illustrator uses to save projects generally requires Adobe Illustrator to open.

How do I open an .AI file on a Mac?

Go to Google Drive here. Select the "My Drive" option. Choose the "Upload File" option. Browse for the Ai file on your computer and open it.


1 Answers

There is one way to do that. That is changing the extension of that ai to pdf and load that and as follows,

- (IBAction)openDocument:(id)sender
{
    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    [previewController setDataSource:self];
    [previewController setDelegate:self];
    [self presentModalViewController:previewController animated:YES];
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
    return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
    return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"pdf"];
}

OUTPUT:

enter image description here

This is working perfectly.. But i dont want to change the EXTENSION. Could anyone help me MORE please.

**

UPDATED ANSWER:

- (IBAction)openDocument:(id)sender
{
    UIButton *button = (UIButton *)sender;
    NSURL *URL = [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];

    if (URL) {
        // Initialize Document Interaction Controller
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

        // Configure Document Interaction Controller
        [self.documentInteractionController setDelegate:self];

        // Present Open In Menu
        [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];
    }
}


- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
    return self;
}

This is showing with menu options but with option BUMP. It works only in device

**

like image 165
Manu Avatar answered Oct 18 '22 07:10

Manu