欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

C#PDFPage操作如何設(shè)置頁面切換按鈕

這篇文章主要介紹C# PDF Page操作如何設(shè)置頁面切換按鈕,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的江城網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

說明

這里的代碼示例需要使用類庫Spire.PDF for .NET,版本4.0 。在使用該類庫時,在項目程序中引用Spire.Pdf.dll即可(dll文件在安裝路徑下的Bin文件中獲取)。

如:

C# PDF Page操作如何設(shè)置頁面切換按鈕

代碼操作示例(供參考)

1.跳轉(zhuǎn)至特定頁(首頁、下一頁、上一頁、最后一頁)

【C#】

using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.Fields;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace ButtonToAppointedPage_PDF
{
 class Program
 {
 static void Main(string[] args)
 {
  //實例化PdfDocument類,加載PDF測試F文檔
  PdfDocument doc = new PdfDocument();
  doc.LoadFromFile("sample.pdf");
  //允許添加Form
  doc.AllowCreateForm = true;
  //獲取文檔最后一頁
  PdfPageBase lastPage = doc.Pages[doc.Pages.Count - 1];
  //在頁面指定位置添加指定大小的按鈕
  PdfButtonField button = new PdfButtonField(lastPage, "Click To Back ");
  button.Bounds = new RectangleF(lastPage.ActualSize.Width - 150, lastPage.ActualSize.Height - 400, 60, 20);
  //設(shè)置按鈕邊框顏色
  button.BorderStyle = PdfBorderStyle.Solid;
  button.BorderColor = new PdfRGBColor(Color.White);
  //設(shè)置按鈕背景色
  button.BackColor = Color.Azure;
  //設(shè)置按鈕提示語 
  button.ToolTip = "To the first page";
  //設(shè)置按鈕文字字體和顏色 
  PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(new Font("Avant Garde", 9f), true);
  button.Font = trueTypeFont;
  button.ForeColor = Color.Black;
  //創(chuàng)建PdfNamedAction實例,在傳入的參數(shù)中選擇上一頁、下一頁、首頁或最后一頁
  PdfNamedAction namedAction = new PdfNamedAction(PdfActionDestination.FirstPage);
  //應(yīng)用動作
  button.Actions.MouseDown = namedAction;
  //添加按鈕到文檔
  doc.Form.Fields.Add(button);
  //保存并打開PDF文檔
  doc.SaveToFile("result.pdf", FileFormat.PDF);
  System.Diagnostics.Process.Start("result.pdf");
 }
 }
}

PS:這里的PdfNameAction類支持四種按鈕跳轉(zhuǎn)動作

C# PDF Page操作如何設(shè)置頁面切換按鈕

添加效果(截圖):

C# PDF Page操作如何設(shè)置頁面切換按鈕

點擊文中的按鈕時,即可跳轉(zhuǎn)至按鈕指向的頁面。

2.跳轉(zhuǎn)至指定頁面

【C#】

using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.Fields;
using Spire.Pdf.General;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace Buttom2
{
 class Program
 {
 static void Main(string[] args)
 {
  //實例化PdfDocument類,加載PDF文檔
  PdfDocument doc = new PdfDocument();
  doc.LoadFromFile("sample.pdf");
  //允許添加Form
  doc.AllowCreateForm = true;
  //獲取最后一頁
  PdfPageBase lastPage = doc.Pages[doc.Pages.Count - 1];
  //在頁面指定位置添加按鈕
  PdfButtonField button = new PdfButtonField(lastPage, "Back");
  button.Bounds = new RectangleF(lastPage.ActualSize.Width - 150, lastPage.ActualSize.Height - 700, 50, 20);
  //設(shè)置按鈕邊框顏色
  button.BorderStyle = PdfBorderStyle.Solid;
  button.BorderColor = new PdfRGBColor(Color.Transparent);
  //設(shè)置按鈕背景色
  button.BackColor = Color.WhiteSmoke;
  //設(shè)置按鈕提示語 
  button.ToolTip = "Click and back to the third page";
  //設(shè)置按鈕文字字體和顏色 
  PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(new Font("Avant Garde", 9f), true);
  button.Font = trueTypeFont;
  button.ForeColor = Color.Black;
  //實例化PdfDestination對象,傳入指定頁碼到第3頁
  PdfDestination destination = new PdfDestination(doc.Pages[2]);
  //創(chuàng)建go to動作
  PdfGoToAction goToAction = new PdfGoToAction(destination);
  //應(yīng)用動作
  button.Actions.MouseDown = goToAction;
  //添加按鈕到文檔
  doc.Form.Fields.Add(button);
  //保存并打開PDF文檔
  doc.SaveToFile("result.pdf", FileFormat.PDF);
  System.Diagnostics.Process.Start("result.pdf");
 }
 }
}

添加效果(截圖):

C# PDF Page操作如何設(shè)置頁面切換按鈕

點擊按鈕,即可跳轉(zhuǎn)至指定的文檔第3頁。

以上是“C# PDF Page操作如何設(shè)置頁面切換按鈕”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站標(biāo)題:C#PDFPage操作如何設(shè)置頁面切換按鈕
網(wǎng)頁地址:http://chinadenli.net/article20/gicdjo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)做網(wǎng)站、商城網(wǎng)站面包屑導(dǎo)航、云服務(wù)器手機網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)