CSharp: Spire.PdfViewer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <%@ Page Language= "C#" AutoEventWireup= "true" CodeBehind= "SpirePDFdemo.aspx.cs" Inherits= "WebAppPdfDemo.SpirePDFdemo" %> <%@ Register Assembly= "Spire.PdfViewer.Asp" Namespace= "Spire.PdfViewer.Asp" TagPrefix= "cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html xmlns= "http://www.w3.org/1999/xhtml" > <head runat= "server" > <meta charset= "UTF-8" > <meta http-equiv= "X-UA-Compatible" content= "IE=edge" > <meta name= "viewport" content= "width=device-width, initial-scale=1.0" > <title>pdf view</title> </head> <body> <form id= "form1" runat= "server" > <div> <cc1:PdfViewer ID= "PdfViewer1" runat= "server" Width= "800px" Height= "800px" > </cc1:PdfViewer> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; using Spire.Pdf; using Spire.PdfViewer; using Spire.Pdf.Graphics; using Spire.Pdf.Tables; using Spire.Pdf.Fields; using Spire.Pdf.Annotations; using Spire.Pdf.Actions; using Spire.Pdf.General; using Spire.Pdf.General.Find; using Spire.PdfViewer.Asp; namespace WebAppPdfDemo { /// <summary> /// /// </summary> public partial class SpirePDFdemo : System.Web.UI.Page { /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load( object sender, EventArgs e) { if (!IsPostBack) { // Creates a pdf document PdfDocument doc = new PdfDocument(); // Creates a new page PdfPageBase page = doc.Pages.Add(); string s1 = "Spire.PDF for .NET is a professional PDF component applied to creating, writing, " + "editing, handling and reading PDF files without any external dependencies within " + ".NET application. Using this .NET PDF library, you can implement rich capabilities " + "to create PDF files from scratch or process existing PDF documents entirely through " + "C#/VB.NET without installing Adobe Acrobat." ; string s2 = "Many rich features can be supported by the .NET PDF API, such as security setting " + "(including digital signature), PDF text/attachment/image extract, PDF merge/split " + ", metadata update, section, graph/image drawing and inserting, table creation and " + "processing, and importing data etc.Besides, Spire.PDF for .NET can be applied to easily " + "converting Text, Image and HTML to PDF with C#/VB.NET in high quality." ; // Get width and height of page float pageWidth = page.GetClientSize().Width; float pageHeight = page.GetClientSize().Height; PdfBrush brush = PdfBrushes.Black; PdfFont font = new PdfFont(PdfFontFamily.TimesRoman, 12f); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify); // Draw text page.Canvas.DrawString(s1, font, brush, new RectangleF(0, 20, pageWidth / 2 - 8f, pageHeight), format); page.Canvas.DrawString(s2, font, brush, new RectangleF(pageWidth / 2 + 8f, 20, pageWidth / 2 - 8f, pageHeight), format); String result = Server.MapPath( "CreateTwoColumnPDF_out.pdf" ); //Save the document doc.SaveToFile(result); //Launch the Pdf file // PDFDocumentViewer(result); //The interval time of emptying caching, specified in seconds. this .PdfViewer1.CacheInterval = 1200; //Caching time of an image, specified in seconds. this .PdfViewer1.CacheTime = 1000; //Cache the number of Image, default is 1000. this .PdfViewer1.CacheNumberImage = 1000; //The time of responding to event after stopping scrolling, specified in milliseconds.default is 500. this .PdfViewer1.ScrollInterval = 300; //Zoom value of page, default is 1. this .PdfViewer1.ZoomFactor = 1; this .PdfViewer1.CustomErrorMessages = "Error information" ; this .PdfViewer1.LoadFromFile( "CreateTwoColumnPDF_out.pdf" ); } } /// <summary> /// /// </summary> /// <param name="fileName"></param> private void PDFDocumentViewer( string fileName) { try { System.Diagnostics.Process.Start(fileName); } catch { } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace CustomizePdfViewerToolBar { /// <summary> /// /// </summary> public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load( object sender, EventArgs e) { string path = @"..\..\..\..\..\..\Data\Multipage.pdf" ; if (File.Exists(path)) { this .pdfDocumentViewer1.LoadFromFile(path); } } } } |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
分类:
CSharp code
标签:
pdf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
2012-01-11 csharp XmlTextReader read xml file