我正在尝试阅读pdf并将第一页保存为图像。此方法适用于http,但它不适用于https。
self.viewInsideScrollView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 375, 950)];
self.viewInsideScrollView.userInteractionEnabled = YES;
self.scrollView.contentSize = CGSizeMake(self.viewInsideScrollView.frame.size.width, self.viewInsideScrollView.frame.size.height);
self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 375, 950)];
self.scrollView.delegate = self;
self.scrollView.scrollEnabled = YES;
self.scrollView.userInteractionEnabled = YES;
self.scrollView.scrollsToTop = YES;
self.scrollView.clipsToBounds = YES;
[self.scrollView addSubview:self.viewInsideScrollView];
policy.xml文件如下所示,未经编辑:
require 'RMagick'
url = "http://www.ke.tu-darmstadt.de/publications/reports/tud-ke-2008-07.pdf"
image = Magick::Image.read(url + "[0]")
=> [http://www.ke.tu-darmstadt.de/publications/reports/tud-ke-2008-07.pdf[0]=>tud-ke-2008-07.pdf PDF 595x842 595x842+0+0 DirectClass 16-bit 27kb]
url = "https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202003%20-%20Machine%20Learning%20in%20Computer%20Chess.pdf"
image = Magick::Image.read(url + "[0]")
Magick::ImageMagickError: not authorized `//www.cs.purdue.edu/homes/dgleich/publications/Gleich%202003%20-%20Machine%20Learning%20in%20Computer%20Chess.pdf' @ error/constitute.c/ReadImage/454
答案 0 :(得分:1)
听起来您的imagemagick政策文件不允许访问https。这是通过看起来像
的指令完成的<policy domain="coder" rights="none" pattern="HTTPS" />
这是最近一轮imagemagick security vulnerabilities之后推荐的policy.xml的一部分。
你当然可以编辑policy.xml来删除它(我不知道如果文件完全丢失,imagemagick是否会抱怨)但是如果您的托管服务提供商可能会让您对这些漏洞感到不满依靠这些动机
另一种选择是下载文件,然后让Rmagick读取该本地文件 - 该策略仅限制ImageMagick执行https访问。