【问题标题】:Generate a ppt file with byte array/NSData, in objective c?在目标c中生成一个带有字节数组/ NSData的ppt文件?
【发布时间】:2016-04-21 10:21:37
【问题描述】:

我有一个从字节数组响应生成的 NSData 值。现在我需要将它保存为 iPhone/iPad 中的 .ppt 文件,我从this 链接了解到没有办法直接这样做。

我已经尝试先将其保存为 PDF,但也失败了,因为我无法从 nsdata 复制图表。

除了通过与设备关联的邮件发送文件之外,还有其他方法可以完成此操作吗?

请只给出我可以在没有用户帮助的情况下在后台执行此操作的方式吗?任何帮助将不胜感激。谢谢

【问题讨论】:

    标签: ios objective-c file download powerpoint


    【解决方案1】:

    我成功了,尝试了很多,但没有成功,最后遇到了一些随机的代码块,使用它我得到了这段美妙的代码,

    //--------------------------------------------------------------------------------generating input URL
    
    NSString *urlAddress = @"url containing the pdf data";
    NSURL *theRessourcesURL = [NSURL URLWithString:urlAddress];
    //--------------------------------------------------------------------------------defining file location details & writing a ppt file with a name "new.ppt"
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *pathFloder = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%@",@"new.ppt"]];
                                                             NSString *defaultDBPath = [documentsDirectory stringByAppendingPathComponent:pathFloder];
    NSData *tmp = [NSData dataWithContentsOfURL:theRessourcesURL];
    [tmp writeToFile:defaultDBPath atomically:YES];
    

    【讨论】:

    • 这似乎不起作用,您已将 pdf 转换为数据并再次将数据写入新文件,您确定会创建一个 ppt 文件吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多