【c#系列】PDF进行操作-浏览、分割、合并、插入、删除(2)

这节我们主要实现缩小、旋转、打印、分割、合并、放大等功能

1、 放大功能

单击放大按钮,实现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();
        }

2、 缩小功能

单击缩小按钮,实现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();
        }

3、 宽度100%显示

单击宽度100%显示按钮,实现PDF宽度100%显示,效果如下:
宽度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;
        }

4、 高度100%显示

单击高度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函数上面有显示。

5、 顺时针旋转

单击顺时针旋转按钮,实现PDF旋转功能:
顺时针旋转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();
        }

6、 逆时针旋转

单击向逆时针旋转按钮,实现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();
        }

源代码下载

单击下载源代码

相关连接

  1. 【c#系列】PDF进行操作-浏览、分割、合并、插入、删除(1)
  2. 【c#系列】PDF进行操作-浏览、分割、合并、插入、删除(2)
  3. 【c#系列】PDF进行操作-浏览、分割、合并、插入、删除(3)
  4. 【c#系列】PDF进行操作-浏览、分割、合并、插入、删除(4)完
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

游戏自学

生活不易,打赏随意

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值