赞
踩
这节我们主要实现缩小、旋转、打印、分割、合并、放大等功能
单击放大按钮,实现PDF放大预览,效果如下:
System.Windows.Forms.ToolStripButton FangDaBT_Tool;
FangDaBT_Tool = new System.Windows.Forms.ToolStripButton();
//
// FangDaBT_Tool
//
FangDaBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
FangDaBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("FangDaBT_Tool.Image")));
FangDaBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
FangDaBT_Tool.Name = "FangDaBT_Tool";
FangDaBT_Tool.Size = new System.Drawing.Size(29, 25);
FangDaBT_Tool.Text = "放大页面";
FangDaBT_Tool.Click += new System.EventHandler(this.FangDaBT_Tool_Click);
private void FangDaBT_Tool_Click(object sender, EventArgs e)
{
ViewerPdf.Renderer.ZoomIn();
}
单击缩小按钮,实现PDF缩小预览,效果如下:
private System.Windows.Forms.ToolStripButton SuoXiaoBT_Tool;
this.SuoXiaoBT_Tool = new System.Windows.Forms.ToolStripButton();
//
// SuoXiaoBT_Tool
//
this.SuoXiaoBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.SuoXiaoBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("SuoXiaoBT_Tool.Image")));
this.SuoXiaoBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
this.SuoXiaoBT_Tool.Name = "SuoXiaoBT_Tool";
this.SuoXiaoBT_Tool.Size = new System.Drawing.Size(29, 24);
this.SuoXiaoBT_Tool.Text = "缩小页面";
this.SuoXiaoBT_Tool.Click += new System.EventHandler(this.SuoXiaoBT_Tool_Click);
private void SuoXiaoBT_Tool_Click(object sender, EventArgs e)
{
ViewerPdf.Renderer.ZoomOut();
}
单击宽度100%显示按钮,实现PDF宽度100%显示,效果如下:
private System.Windows.Forms.ToolStripButton HengBT_Tool;
this.HengBT_Tool = new System.Windows.Forms.ToolStripButton();
//
// HengBT_Tool
//
this.HengBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.HengBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("HengBT_Tool.Image")));
this.HengBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
this.HengBT_Tool.Name = "HengBT_Tool";
this.HengBT_Tool.Size = new System.Drawing.Size(29, 24);
this.HengBT_Tool.Text = "横向100%";
this.HengBT_Tool.Click += new System.EventHandler(this.HengBT_Tool_Click);
private void HengBT_Tool_Click(object sender, EventArgs e)
{
FitPage(PdfViewerZoomMode.FitWidth);
}
/// <summary>
/// 适时显示页面
/// </summary>
/// <param name="zoomMode"></param>
private void FitPage(PdfViewerZoomMode zoomMode)
{
int page = ViewerPdf.Renderer.Page;
ViewerPdf.ZoomMode = zoomMode;
ViewerPdf.Renderer.Zoom = 1;
ViewerPdf.Renderer.Page = page;
}
单击高度100%显示按钮,实现PDF高度100%显示:
private System.Windows.Forms.ToolStripButton ShuxiangBT_Tool;
this.ShuxiangBT_Tool= new System.Windows.Forms.ToolStripButton();
//
// ShuxiangBT_Tool
//
this.ShuxiangBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ShuxiangBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("ShuxiangBT_Tool.Image")));
this.ShuxiangBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ShuxiangBT_Tool.Name = "ShuxiangBT_Tool";
this.ShuxiangBT_Tool.Size = new System.Drawing.Size(29, 24);
this.ShuxiangBT_Tool.Text = "竖向100%";
this.ShuxiangBT_Tool.Click += new System.EventHandler(this.ShuxiangBT_Tool_Click);
private void ShuxiangBT_Tool_Click(object sender, EventArgs e)
{
FitPage(PdfViewerZoomMode.FitHeight);
}
FitPage函数上面有显示。
单击顺时针旋转按钮,实现PDF旋转功能:
private System.Windows.Forms.ToolStripButton ShunBT_Tool;
this.ShunBT_Tool= new System.Windows.Forms.ToolStripButton();
//
// ShunBT_Tool
//
this.ShunBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ShunBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("ShunBT_Tool.Image")));
this.ShunBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ShunBT_Tool.Name = "ShunBT_Tool";
this.ShunBT_Tool.Size = new System.Drawing.Size(29, 24);
this.ShunBT_Tool.Text = "顺时针旋转Pdf";
this.ShunBT_Tool.Click += new System.EventHandler(this.ShunBT_Tool_Click);
/// <summary>
/// 顺时针旋转PDF
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShunBT_Tool_Click(object sender, EventArgs e)
{
ViewerPdf.Renderer.RotateRight();
}
单击向逆时针旋转按钮,实现PDF旋转功能:
private System.Windows.Forms.ToolStripButton NiBT_Tool;
this.NiBT_Tool= new System.Windows.Forms.ToolStripButton();
// NiBT_Tool
//
this.NiBT_Tool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.NiBT_Tool.Image = ((System.Drawing.Image)(resources.GetObject("NiBT_Tool.Image")));
this.NiBT_Tool.ImageTransparentColor = System.Drawing.Color.Magenta;
this.NiBT_Tool.Name = "NiBT_Tool";
this.NiBT_Tool.Size = new System.Drawing.Size(29, 24);
this.NiBT_Tool.Text = "逆时针旋转Pdf";
this.NiBT_Tool.Click += new System.EventHandler(this.NiBT_Click);
/// <summary>
/// 逆时针旋转PDF
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NiBT_Click(object sender, EventArgs e)
{
ViewerPdf.Renderer.RotateLeft();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。