public void init(bool useAcroPDF) { if (useAcroPDF && this.axAcroPDF == null) { this.axAcroPDF = new AxAcroPDF(); initAxAcroPDF(); } else if (!useAcroPDF && this.pdfRenderer == null) { this.pdfRenderer = new PdfRenderer(); initPdfRenderer(); } }
/// <summary> /// 在一个Panel中显示pdf文件(Form) /// </summary> /// <param name="body_panel">显示pdf文件的panel</param> /// <param name="pdf_path">pdf文件路径</param> /// <param name="ParentFormType">父窗体的类别</param> /// <returns>AxAcroPDF 实例, 显示失败返回null</returns> public static object show(Panel body_panel, string pdf_path) { if ((!File.Exists(pdf_path) && !PDFUtil.JudgeFileExist(pdf_path)) || !(pdf_path.Trim().ToLower().EndsWith(".pdf"))) { return(null); } if (body_panel == null) { return(null); } AxAcroPDF pdf = null; foreach (Control c in body_panel.Controls) { if (c.Name == PDF_BODY_NAME) { try { pdf = c as AxAcroPDF; break; } catch { } } } if (pdf == null) { try { pdf = new AxAcroPDF(); ((System.ComponentModel.ISupportInitialize)(pdf)).BeginInit(); pdf.Dock = DockStyle.Fill; pdf.Enabled = true; pdf.Location = new System.Drawing.Point(0, 0); pdf.Name = PDF_BODY_NAME; pdf.TabIndex = 1; pdf.Parent = body_panel; ((System.ComponentModel.ISupportInitialize)(pdf)).EndInit(); pdf.Visible = true; pdf.Height = body_panel.Height; pdf.Width = body_panel.Width; } catch { MessageBox.Show("PDF显示组件初始化错误,请检查是否安装Acrobat Reader 9及以上版本!"); return(null); } } pdf.src = pdf_path; pdf.Invalidate(); return(pdf); }
/// <summary> /// Metodo que hace bisible el plugin Adobe Reader para la visualizacion de documentos PDF /// </summary> /// <param name="axAcroPDF">Instancia que se mostrara</param> /// <returns>Booleano que indica si la operacion se realizo de manera correcta</returns> public bool MostrarPDF(AxAcroPDF axAcroPDF) { String source = datosArchivo.Ruta + "\\" + datosArchivo.NombreArchivo; if (File.Exists(source)) { axAcroPDF.src = source; axAcroPDF.Visible = true; return(true); } else { MessageBox.Show("Archivo no encontrado!\n\nBuscamos: " + source + "\n\nPISTA: Si cuenta con el archivo, llevelo a la ubicación correcta y vuelva intente abrirlo. Caso contrario vuelva a escanear el documento.", "ARCHIVO NO ENCONTRADO!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } }
/// <summary> /// 打印PDF文件 /// </summary> /// <param name="printer_name"></param> /// <param name="file_path"></param> /// <param name="ax_acropdfunit"></param> /// <returns></returns> public static string print(string printer_name, string file_path, AxAcroPDF ax_acropdfunit) { try { if (!printer_name.isNull()) { string default_printer = PrintUtil.defaultPrinter(); if (default_printer != printer_name) { PrintUtil.setDefaultPrinter(printer_name); while (PrintUtil.defaultPrinter() != printer_name) { Thread.Sleep(50); } Thread.Sleep(1000); } } ax_acropdfunit.LoadFile(file_path); ax_acropdfunit.printAllFit(true); return(""); } catch (Exception ex) { return(ex.ToString()); } }
public AxAcroPDFEventMulticaster(AxAcroPDF parent) { this.parent = parent; }
public void SetReader(AxAcroPDF pdfReader) { this.pdfReader = pdfReader; }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "PDF File (*.pdf)|*.pdf|Image File (*.bmp,*.jpg,*.jpeg,*.png,*.tif,*.tiff,*.ico,*.TIF)|*.bmp;*.jpg;*.jpeg;*.png;*.tif;*.tiff;*.ico;*.TIF"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { Form ReaderForm = new Form(); ReaderForm.MdiParent = this; FileInfo fileInfo = new FileInfo(openFileDialog.FileName); switch (fileInfo.Extension) { case ".pdf": { toolStripStatusLabel.Text = "Openning PDF Reader..."; //statusBarToolStripMenuItem.Invalidate(); AxAcroPDF pdfReader = new AxAcroPDF(); ((ISupportInitialize)(pdfReader)).BeginInit(); pdfReader.CreateControl(); pdfReader.Enabled = true; pdfReader.Dock = DockStyle.Fill; pdfReader.Name = "AxAcroPDFReader"; pdfReader.Visible = true; pdfReader.LoadFile(fileInfo.FullName); ReaderForm.Controls.Add(pdfReader); pdfReader.Show(); ((ISupportInitialize)(pdfReader)).EndInit(); ReaderForm.Text = "PDF Reader"; toolStripStatusLabel.Text = "PDF Reader Opened"; //statusBarToolStripMenuItem.Invalidate(); } break; case ".jpg": case ".png": case ".ico": case ".tiff": case ".TIF": case ".bmp": case ".jpeg": case ".tif": { toolStripStatusLabel.Text = "Openning Image Reader..."; //statusBarToolStripMenuItem.Invalidate(); PictureBox pictureBox = new PictureBox(); pictureBox.ImageLocation = fileInfo.FullName; pictureBox.SizeMode = PictureBoxSizeMode.AutoSize; pictureBox.Dock = DockStyle.Fill; pictureBox.Visible = true; pictureBox.Enabled = true; ReaderForm.Controls.Add(pictureBox); pictureBox.Show(); ReaderForm.Text = "Image Reader"; toolStripStatusLabel.Text = "Image Reader Opened"; //statusBarToolStripMenuItem.Invalidate(); } break; } ReaderForm.Show(); } }
public Acrobat7Displayer() { _axPdf = new AxAcroPDF(); _axPdf.Enabled = true; _axPdf.Name = "_axPdf"; }
/// <summary> /// 打印PDF文件 /// </summary> /// <param name="file_path"></param> /// <param name="ax_acropdfunit"></param> /// <returns></returns> public static string print(string file_path, AxAcroPDF ax_acropdfunit) { return(print("", file_path, ax_acropdfunit)); }