Csharp:user WebControl Read Adobe PDF Files In Your Web Browser

简介: namespace GeovinDu.PdfViewer { [DefaultProperty("FilePath")] [ToolboxData("<{0}:ShowPdf runat=server></{0}:ShowPdf>")] public class ShowPdf : WebControl {
namespace GeovinDu.PdfViewer
{
    [DefaultProperty("FilePath")]
    [ToolboxData("<{0}:ShowPdf runat=server></{0}:ShowPdf>")]   
    public class ShowPdf : WebControl
    {
        
#region "Declarations" 
        //Geovin Du 塗聚文 20131010
        private string mFilePath;

#endregion



        #region "Properties" 

        [Category("Source File")]
        [Browsable(true)]
        [Description("Set path to source file.")]
        [Editor(typeof(System.Web.UI.Design.UrlEditor), typeof(System.Drawing.Design.UITypeEditor))]
        public string FilePath
        {
            get
            {
                return mFilePath;
            }
            set
            {
                if (value == string.Empty)
                {
                    mFilePath = string.Empty;
                }
                else
                {
                    int tilde = -1;
                    tilde = value.IndexOf('~');
                    if (tilde != -1)
                    {
                        mFilePath = value.Substring((tilde + 2)).Trim();
                    }
                    else
                    {
                        mFilePath = value;
                    }
                }
            }
        }   // end FilePath property


#endregion


        
#region "Rendering"
        /// <summary>
        ///  Geovin Du 塗聚文 20131010
        /// </summary>
        /// <param name="writer"></param>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<iframe src=" + FilePath.ToString() + " ");
                sb.Append("width=" + Width.ToString() + " height=" + Height.ToString() + " ");
                sb.Append("<View PDF: <a href=" + FilePath.ToString() + "</a></p> ");
                sb.Append("</iframe>");

                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write(sb.ToString());
                writer.RenderEndTag();
            }
            catch
            {
                // with no properties set, this will render "Display PDF Control" in a
                // a box on the page
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write("Display PDF Control");
                writer.RenderEndTag();
            }  // end try-catch
        }   // end RenderContents


        #endregion

    }   // end class
}       // end namespace  Geovin Du 塗聚文 20131010

目录
相关文章
|
1月前
|
应用服务中间件
使用 Adobe Livecycle Enterprise service 将 word 文档转换成 PDF 格式
使用 Adobe Livecycle Enterprise service 将 word 文档转换成 PDF 格式
|
1月前
SpringCloud启动Consider defining a bean of type ‘org.springframework.web.client.RestTemplate‘ in your
SpringCloud启动Consider defining a bean of type ‘org.springframework.web.client.RestTemplate‘ in your
44 1
|
8月前
|
存储 XML BI
如何把 SAP ABAP 系统里一张数据库表的内容,显示在 Adobe PDF Form 里试读版
如何把 SAP ABAP 系统里一张数据库表的内容,显示在 Adobe PDF Form 里试读版
|
8月前
|
XML 存储 Java
使用 ABAP 调用 Adobe Document Service 生成 PDF 文档
使用 ABAP 调用 Adobe Document Service 生成 PDF 文档
|
Windows
PDF工具Adobe Arcrobat Pro DC下载安装教程
Acrobat是一款PDF(Portable Document Format,便携式文档格式)编辑软件。借助它,您可以以PDF格式制作和保存你的文档 ,以便于浏览和打印,或使用更高级的功能。
660 0
|
安全 Windows
Adobe 和微软通过微软边缘为 1 亿 Windows 用户带来行业领先的 Acrobat PDF 体验
Adobe 和微软通过微软边缘为 1 亿 Windows 用户带来行业领先的 Acrobat PDF 体验。
Adobe 和微软通过微软边缘为 1 亿 Windows 用户带来行业领先的 Acrobat PDF 体验
PDF - 使用 Adobe Acrobat 压缩 PDF 大小
PDF - 使用 Adobe Acrobat 压缩 PDF 大小
401 0
PDF - 使用 Adobe Acrobat 压缩 PDF 大小
|
Unix Linux iOS开发
卸载Adobe Reader!一款免费、好用、轻量的PDF阅读器
一直以来,有不少同学问过我“有没有比较好用的PDF阅读器?”
卸载Adobe Reader!一款免费、好用、轻量的PDF阅读器
|
算法 安全 编译器
PDF之父、Adobe联合创始人离世,乔布斯收购未果给了他第一桶金
Adobe的传奇创始人离世,对艺术世界影响巨大的开发者,pdf、photoshop都是他的成名作。
243 0
PDF之父、Adobe联合创始人离世,乔布斯收购未果给了他第一桶金
|
机器学习/深度学习 人工智能 算法
手机看PDF有救了!Adobe发布「Liquid Mode」液体模式自适应手机屏幕
Adobe近日在手机应用程序Acrobat Reader中发布了一个叫做「Liquid Mode」液体模式的功能,可以根据智能手机的屏幕大小来自适应调节PDF的排版,获得更好的效果。
766 0
手机看PDF有救了!Adobe发布「Liquid Mode」液体模式自适应手机屏幕

热门文章

最新文章