我使用以下简单代码加载pdf表单,但我不希望以可编辑的形式加载它。我没有找到任何限制它的内容在仅查看模式下加载。
elasticsearch_dsl
由于
答案 0 :(得分:0)
我认为您想禁用LongPressGestureRecognizer。像这样:
private static void DisableDefaultLongPressGestureRecognizer(PdfKit.PdfView oPdfView)
{
oPdfView
.GestureRecognizers
.Where(x => x is UILongPressGestureRecognizer)
.ForEach((oLongPressGestureRecognizer, nIndex) =>
{
oLongPressGestureRecognizer.Enabled = false;
});
}
答案 1 :(得分:0)
在显示文档之前,我可以通过在文档的其他注释上添加空白注释来做到这一点。我在PDF文档中添加了一个 makeReadOnly()扩展名,该扩展名用于所有注释,以使整个文档只读。
这样做的好处是所有其他PDF查看功能仍然可以正常工作。这是Swift代码。您可以对Objective-C类别执行类似的操作:
// A blank annotation that does nothing except serve to block user input
class BlockInputAnnotation: PDFAnnotation {
init(forBounds bounds: CGRect, withProperties properties: [AnyHashable : Any]?) {
super.init(bounds: bounds, forType: PDFAnnotationSubtype.stamp, withProperties: properties)
self.fieldName = "blockInput"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func draw(with box: PDFDisplayBox, in context: CGContext) {
}
}
extension PDFDocument {
func makeReadOnly() {
for pageNumber in 0..<self.pageCount {
guard let page = self.page(at: pageNumber) else {
continue
}
for annotation in page.annotations {
annotation.isReadOnly = true // This _should_ be enough, but PDFKit doesn't recognize the isReadOnly attribute
// So we add a blank annotation on top of the annotation, and it will capture touch/mouse events
let blockAnnotation = BlockInputAnnotation(forBounds: annotation.bounds, withProperties: nil)
blockAnnotation.isReadOnly = true
page.addAnnotation(blockAnnotation)
}
}
}
}