• c#使用免费开源.net的pdf操作控件PdfiumViewer


    记录自己在学习园里大神文章时遇到的问题,以备自己复习

     文章原址:通过PdfiumViewer.dll实现pdf直接从流显示(效果不好) 

    https://www.cnblogs.com/mol1995/p/6078733.html

    原文内容如下:

    开源的PdfiumViewer.dll并不完整

    需要不开源的pdfium.dll配合使用

    引用只需添加PdfiumViewer.dll,但pdfium.dll必须跟它放在一个路径下

    界面中添加控件:

    PdfiumViewer.PdfViewer pdfViewer1 = new PdfiumViewer.PdfViewer();

                pdfViewer1.Location = new Point(0, 24);

                pdfViewer1.Size = new Size(300, 300);

                pdfViewer1.Dock = DockStyle.Fill;

                this.Controls.Add(pdfViewer1);

                pdfViewer1.Document = PdfDocument.Load(@"D:NAIP解压临时文件夹2016-12P.pdf");

    打开后只有另存、打印、放大、缩小菜单,没有旋转菜单,也不支持鼠标滚轮缩放。

    实验过程:1. 首先在新建的项目 Debug路径下,添加了一个other文件夹,并在里面添加了PdfiumViewer.dll和pdfium.dll

                  2.在编辑界面的引用中添加PdfiumViewer.dll,我引用时的路径,选择了other文件夹

               3.在主窗体,添加一个按钮,将如上的代码复制进去,注意不要忘了 using PdfiumViewer;

                PdfiumViewer.PdfViewer pdfViewer1 = new PdfiumViewer.PdfViewer();

                pdfViewer1.Location = new Point(0, 24);

                pdfViewer1.Size = new Size(300, 300);

                pdfViewer1.Dock = DockStyle.Fill;

                this.Controls.Add(pdfViewer1);

                pdfViewer1.Document = PdfDocument.Load(@"D:NAIP解压临时文件夹2016-12P.pdf");

                4.点击运行,出现报警  

     此时有点郁闷,我是放在一个路径了(other文件夹下),但是还是报警了,百度报警文本,借鉴了 文章 System.DllNotFoundException:"无法加载DLL"**.dll":找不到指定的模块 (https://www.cnblogs.com/Johnson2580/p/12329877.html)中的内容,“非托管代码dll并没有在原dll的引用里面,所有将非托管代码拷贝到自己的debug目录下再重新生成”

            5.测试通过

    6.总结,

     引用只需添加PdfiumViewer.dll,但pdfium.dll必须跟它放在一个路径下。哪里需要注意的,请大神们指点知识点!

  • 相关阅读:
    C# 实现 Aop [Emit动态生成代理类方式]
    分享一些最近在看的电子书
    Can't connect to your phone. Disconnect it, restart it, then try connecting again
    07,Windows Phone后台代理
    .NET 性能测试工具 性能计数器
    windows 8 metro 开发学习资源链接
    08,Windows Phone 本地存储
    06,Windows Phone 8程序的生命周期
    .NET 性能测试工具 事件跟踪器(ETW)
    LitJSONjson 和net 的完美组合用法
  • 原文地址:https://www.cnblogs.com/841019rossi/p/14873815.html
Copyright © 2020-2023  润新知