Goran Bibic

Goran Bibic

  • 484
  • 2.9k
  • 196.8k

Read PDF file from sql to AxAcroPDF c#

Jul 31 2018 4:37 AM
Some help?
 
I try this but dont work, no have errors but not read file...please help
 
  1. {  
  2.             if (documentsDataGridView.SelectedRows.Count > 0)  
  3.             {  
  4.   
  5.                 string id = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn1"].Value.ToString();  
  6.                 string number = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn2"].Value.ToString();  
  7.                 string count_number = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn3"].Value.ToString();  
  8.                 string label = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn4"].Value.ToString();  
  9.                 string partner = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn5"].Value.ToString();  
  10.                 string tax_number = documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn6"].Value.ToString();  
  11.                 string file_location = documentsDataGridView.SelectedRows[0].Cells["file_location"].Value.ToString();  
  12.                 //string pdf_file = documentsDataGridView.SelectedRows[0].Cells["pdf_file"].Value.ToString();  
  13.   
  14.   
  15.                 idTextBox.Text = id;  
  16.                 numberTextBox.Text = number;  
  17.                 count_numberTextBox.Text = count_number;  
  18.                 labelTextBox.Text = label;  
  19.                 partnerComboBox.Text = partner;  
  20.                 tax_numberTextBox.Text = tax_number;  
  21.                 dateDateTimePicker.Value = Convert.ToDateTime(documentsDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn7"].Value);  
  22.                 file_locationTextBox.Text = file_location;  
  23.                 //axAcroPDF1.src = pdf_file;  
  24.   
  25.   
  26.   
  27.                 try  
  28.                 {  
  29.                     if (documentsDataGridView.SelectedRows[0].Cells["pdf_file"].Value != null)  
  30.   
  31.                     {  
  32.                         byte[] ap = (byte[])(documentsDataGridView.SelectedRows[0].Cells["pdf_file"].Value);  
  33.                         MemoryStream ms = new MemoryStream(ap);  
  34.                         axAcroPDF1.src = LocalEncoding.GetString(ms.ToArray());  
  35.                         //axAcroPDF1.LoadFile(ms);  
  36.   
  37.   
  38.                     }  
  39.                     else  
  40.                     {  
  41.                         axAcroPDF1.src = null;  
  42.                     }  
  43.                 }  
  44.                 catch  
  45.                 {  
  46.                     axAcroPDF1.src = null;  
  47.                 }  
  48.   
  49.   
  50.             }  
  51.         } 
 

Answers (5)