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

 2023-09-16 阅读 15 评论 0

摘要:namespace GeovinDu.PdfViewer {[DefaultProperty("FilePath")][ToolboxData("<{0}:ShowPdf runat=server></{0}:ShowPdf>")] public class ShowPdf : WebControl{#region "Declarations" //Geovin Du 塗聚文 20131010private strin
namespace GeovinDu.PdfViewer
{[DefaultProperty("FilePath")][ToolboxData("<{0}:ShowPdf runat=server></{0}:ShowPdf>")]   public class ShowPdf : WebControl{#region "Declarations" //Geovin Du 塗聚文 20131010private 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 pagewriter.RenderBeginTag(HtmlTextWriterTag.Div);writer.Write("Display PDF Control");writer.RenderEndTag();}  // end try-catch}   // end RenderContents#endregion}   // end class
}       // end namespace  Geovin Du 塗聚文 20131010

 

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/68278.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息