以特定縮放系數(shù)/百分比打開 PDF 文件
Spire.PDF for .NET 是一款專門對 Word 文檔進行操作的 .NET 類庫。致力于在于幫助開發(fā)人員輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔,而無需安裝 Microsoft Word。
行號用于在每行文本旁邊顯示 Word 自動計算的行數(shù)。當(dāng)我們需要參考合同或法律文件等文檔中的特定行時,它非常有用。word中的行號功能允許我們設(shè)置起始值、編號間隔、與文本的距離以及行號的編號方式。使用 Spire.Doc,我們可以實現(xiàn)上述所有功能。本文將介紹如何將 HTML 轉(zhuǎn)換為 PDF。
歡迎加入spire技術(shù)交流群:767755948
我們可能需要在顯示 PDF 文件時更改縮放系數(shù),以滿足我們的要求。在本文中,我們將演示如何使用 Spire.PDF for .NET 以特定縮放系數(shù)/百分比(如默認(rèn)、100% 或所需的任何其他縮放系數(shù))打開 PDF 文件。
檢查 PDF 文件的原始縮放系數(shù),如下圖所示:
 
 
然后參考以下詳細步驟:
第 1 步:創(chuàng)建一個新的 PdfDocument 類實例,加載原始 PDF 文件并獲取其第一頁。
PdfDocument pdf = new PdfDocument("Stories.pdf");         
PdfPageBase page = pdf.Pages[0];
 第 2 步:使用PdfDestination(PdfPageBase page, PointF location)類創(chuàng)建一個新的PdfDestination對象,該類有兩個參數(shù):頁面和頁面顯示位置。然后將其縮放屬性值設(shè)置為特定的縮放因子/百分比。PdfDestination dest = new PdfDestination(page, new PointF(-40f, -40f)); // Here we set its zoom factor to 100%. If you want to set the zoom factor to default, please set the value of zoom property to 0f. dest.Zoom = 1f;第 3 步:創(chuàng)建 PdfGoToAction 類的新實例,并啟用縮放因子重置操作,以便在打開 PDF 文件時執(zhí)行該操作。
PdfGoToAction gotoaction = new PdfGoToAction(dest); pdf.AfterOpenAction = gotoaction;第 4 步:保存 PDF 文件。
pdf.SaveToFile("result.pdf");
 PDF 文件的結(jié)果縮放系數(shù): 
 
完整代碼:
[C#]
using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.General;
using System.Drawing;
namespace Set_the_zoom_factor
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument("Stories.pdf");         
            PdfPageBase page = pdf.Pages[0];
            PdfDestination dest = new PdfDestination(page, new PointF(-40f, -40f));
            dest.Zoom = 1f;
            PdfGoToAction gotoaction = new PdfGoToAction(dest);
            pdf.AfterOpenAction = gotoaction;
            pdf.SaveToFile("result.pdf");
        }
    }
}
[VB.NET] 
Imports Spire.Pdf
Imports Spire.Pdf.Actions
Imports Spire.Pdf.General
Imports System.Drawing
Namespace Set_the_zoom_factor
	Class Program
		Private Shared Sub Main(args As String())
			Dim pdf As New PdfDocument("Stories.pdf")
			Dim page As PdfPageBase = pdf.Pages(0)
			Dim dest As New PdfDestination(page, New PointF(-40F, -40F))
			dest.Zoom = 1F
			Dim gotoaction As New PdfGoToAction(dest)
			pdf.AfterOpenAction = gotoaction
			pdf.SaveToFile("result.pdf")
		End Sub
	End Class
End Namespace                
            
 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網(wǎng)安備
            50010702500608號
渝公網(wǎng)安備
            50010702500608號
             
            
 客服熱線
客服熱線