using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace ICSSoft.Frame.APP { public partial class PDFviewerControl : UserControl { public PDFviewerControl() { InitializeComponent(); } private void btnRotateLeft_Click(object sender, EventArgs e) { pdfViewer1.Renderer.RotateLeft(); } private void btnRotateRight_Click(object sender, EventArgs e) { pdfViewer1.Renderer.RotateRight(); } /// /// 加载pdf文件 /// /// 文件绝对路径 public void LoadFile(string fullfilename) { if (pdfViewer1.Document != null) { pdfViewer1.Document.Dispose(); } pdfViewer1.Document = OpenDocument(fullfilename); } private PdfiumViewer.PdfDocument OpenDocument(string fileName) { try { MemoryStream ms = new MemoryStream(); using (FileStream fs = new FileStream(fileName, FileMode.Open)) { fs.CopyTo(ms); fs.Close(); } PdfiumViewer.PdfDocument doc = PdfiumViewer.PdfDocument.Load(ms); return doc; } catch (Exception ex) { MessageBox.Show(this, ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } } public void Close() { if (pdfViewer1.Document != null) { pdfViewer1.Document.Dispose(); } pdfViewer1.Dispose(); this.Dispose(); } private void btnPre_Click(object sender, EventArgs e) { pdfViewer1.Renderer.Page--; } private void btnNext_Click(object sender, EventArgs e) { pdfViewer1.Renderer.Page++; } } }