2011-11-02 86 views
0

我想加載沒有工具欄的PDF文件。 如果我直接使用iframe加載pdf文件意味着它不會顯示工具欄 (工作正常的工具欄)。但如果我以編程方式這樣做意味着它顯示工具欄,即使我給工具欄= 0。 所以如何處理這個問題。在asp.net隱藏PDF工具欄

下面的代碼是程序化的pdf加載。但它顯示了工具欄。

protected void Page_Load(object sender, EventArgs e) 
{ 
    byte[] content =FileToByteArray(Server.MapPath("Test.pdf")); 
    Response.ContentType = "application/pdf"; 
    Response.AddHeader("Content-Disposition", "inline; filename=Test.pdf#toolbar=0"); 
    Response.BinaryWrite(content); 
    Response.End(); 
} 


/// <summary> 
/// Function to get byte array from a file 
/// </summary> 
/// <param name="_FileName">File name to get byte array</param> 
/// <returns>Byte Array</returns> 
public byte[] FileToByteArray(string _FileName) 
{ 
    byte[] _Buffer = null; 

    try 
    { 
     // Open file for reading 
     System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read); 

     // attach filestream to binary reader 
     System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream); 

     // get total byte length of the file 
     long _TotalBytes = new System.IO.FileInfo(_FileName).Length; 

     // read entire file into buffer 
     _Buffer = _BinaryReader.ReadBytes((Int32)_TotalBytes); 

     // close file reader 
     _FileStream.Close(); 
     _FileStream.Dispose(); 
     _BinaryReader.Close(); 
    } 
    catch (Exception _Exception) 
    { 
     // Error 
     Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()); 
    } 

    return _Buffer; 
} 


need ur suggestions with examples. 

問候 庵埠

+0