在Adobe AxAcroPDFLib启用注解 [英] Enabling annotation in Adobe AxAcroPDFLib

查看:1895
本文介绍了在Adobe AxAcroPDFLib启用注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用嵌入PDF查看器在C#WinForm的 AxAcroPDFLib 。 然而,工具栏中的注释按钮(评论...)被禁用。 我搜索,发现他们被默认禁用,但一些报道让他们使用Javascript:

I embedded a PDF viewer in a C# Winform using AxAcroPDFLib. However, the annotation buttons in the toolbar (comments...) are disabled. I searched and found that they are disabled by default, but some reported enabling them using Javascript:

Collab.showAnnotToolsWhenNoCollab = True

有没有办法在这里做到这一点?

Is there a way to do this here?

编辑:是否有可能使用的浏览器插件在WebBrowser控件?如果是这样,这可怎么办呢?

Is it possible to use the browser plugin in a WebBrowser Control? If so, how can this be done?

推荐答案

更新 - 第一部分是只与Acrobat Reader软件。对于使用Acrobat的完整版本时的信息,请参见第二部分。

Acrobat Reader软件

我会preface这一切时指出,这是的也许的不是你要找的答案,但我觉得这值得更多的不仅仅是一个注释说明。

I'll preface all of this by stating this is probably not the answer you're looking for, but I felt this warranted more of an explanation than just a comment.

有一个类似的,自回答问题,有人问SO(<一href="http://stackoverflow.com/questions/4737456/adobe-reader-x-10-0-activex-annotations-are-disabled">here),其中OP得出结论,这种行为是设计使然,没有什么不能做什么呢,这我同意,差不多了。

A similar, self-answered question was asked on SO (here), where the OP came to the conclusion that this behavior is by design and nothing cannot be done about it, which I agree with, almost.

虽然我敢肯定,你已经看到了阅读器本身可以是文档加载为读者启用,在这一点上标注添加注释,使用Reader插件(AcroPDFLib)解决这个问题的唯一直接的方法可用就像他们在阅读器。如果你有你想要的插件加载的文件的控制权,这可能是你的解决方案。

While I'm sure you've seen that Reader itself can add annotations, the only straightforward means of accomplishing this using the Reader Plugin (AcroPDFLib) is for the document being loaded to be "Reader Enabled," at which point annotations become available just as they are in Reader. If you have control of the documents you wish the plugin to load, this may be a solution for you.

要你关于可能设置的问题 Col​​lab.showAnnotToolsWhenNoCollab = TRUE 作为一种解决办法,我只搜索显示这是一个可行的解决方法对于那些使用完整版本的Acrobat,而不是读者。更具体地讲,在一个Adobe论坛(这里),就用一个Adobe员工评论直接将此属性:

To your question about possibly setting Collab.showAnnotToolsWhenNoCollab = True as a workaround, my searches only showed this being a viable workaround for those using a full version of Acrobat, not Reader. More specifically, on an Adobe forum (here), an Adobe staff commented on the use of this property directly:

没有,这不是[关于允许注释在Adobe Reader。它是   关于在浏览器中启用注释为Acrobat Standard或   专业版。如果您想启用评论在阅读器中,那么你   需要读者开启自己使用Acrobat专业的PDF文件   或Adobe ActionScript 3.0语言读取器扩展服务器。

No, it is not [about allowing commenting in Adobe Reader]. It is about enabling commenting in a browser for Acrobat Standard or Professional. If you wish to enable commenting in Reader, then you need to "Reader Enable" the PDFs themselves using Acrobat professional or Adobe Livecycle Reader Extension Server.

当然,这种评论是在引用到Acrobat 9,它似乎仍然有效为Acrobat XI。

Granted, this comment was in reference to Acrobat 9, it appears to still be valid for Acrobat XI.

最后一个位。我不知道你的应用程序的范围,所以这可能是完全不相干的,但如果这是一个商业应用,即使你找到一个功能的解决方法,我会很犹豫使用它,因为它可能违反的Adobe阅读许可协议(这里);特别是第4.3.3,残疾人特点。短的版本是,与大多数公司来说,他们不想让你绕过他们的保护。

One last bit. I don't know the scope of your application, so this may be completely irrelevant, but if this is a commercial application, even if do you find a functional workaround, I'd be hesitant to use it, as it might violation the Adobe Reader license agreement (here); specifically section 4.3.3, Disabled Features. The short version is, as with most companies, they don't want you circumventing their protections.

完整版本的Acrobat

下面code将创建一个PDF浏览器(使用表格的窗口图),打开PDF,然后设置 collab.showAnnotToolsWhenNoCollab = TRUE 允许注解在打开的PDF。这需要参考的Acrobat类型库。

The following code will create a PDF viewer (using the Form's window for drawing), open a PDF, then set collab.showAnnotToolsWhenNoCollab = true to allow annotations on the open PDF. This requires a reference to the Acrobat type library.

void CreatePdfViewerAndOpenFile(string pdfFile)
{
    short AV_DOC_VIEW = 2;
    short PDUseBookmarks = 3;
    short AVZoomFitWidth = 2;

    Type AcroExch_AVDoc = Type.GetTypeFromProgID("AcroExch.AVDoc");
    _acroExchAVDoc = (Acrobat.CAcroAVDoc)Activator.CreateInstance(AcroExch_AVDoc);
    bool ok = _acroExchAVDoc.OpenInWindowEx(pdfFile, this.Handle.ToInt32(), AV_DOC_VIEW, -1, 0, PDUseBookmarks, AVZoomFitWidth, 0, 0, 0);

    if (ok)
    {
        CAcroPDDoc pdDoc = (CAcroPDDoc)_acroExchAVDoc.GetPDDoc();
        object jsObj = pdDoc.GetJSObject();
        Type jsObjType = jsObj.GetType();
        object collab = jsObjType.InvokeMember("collab",
            BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance,
            null, jsObj, null);

        jsObjType.InvokeMember("showAnnotToolsWhenNoCollab",
            BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance,
            null, collab, new object[] { true });
    }
}

呼叫无论你想要显示的PDF此方法。完成后,一定要叫关闭法或PDF文件将保持开放的过程中的Acrobat在后台。

Call this method from wherever you want to display the PDF. When finished, be sure to call the Close method or the PDF file will remain open in the Acrobat process in the background.

_acroExchAVDoc.Close(-1);

请记住,很多正常的功能被省略了这个例子,像的形式调整大小处理等方面,但它应该让你开始。由于调整大小不是由这个例子来处理,你可能需要到窗体调用方法之前最大化,所以观众是大到足以成为有用的。有关如何使用浏览器以这种方式的更多信息,请下载Acrobat的SDK(这里 ),并期待在ActiveViewVB示例项目,这是我用来建立一些这方面的例子。作为参考,我用的Acrobat XI SDK。

Bear in mind that a lot of "normal" functionality is left out of this example, like form resize handling, etc., but it should get you started. Because resizing isn't handled by this example, you'll probably want to maximize the form before invoking the method, so the viewer is big enough to be useful. For more information on how to use the viewer in this fashion, download the Acrobat SDK (here) and look at the ActiveViewVB sample project, which is what I used to build some of this example. For reference, I used the Acrobat XI SDK.

这篇关于在Adobe AxAcroPDFLib启用注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆