LavanKumar R

LavanKumar R

  • NA
  • 3
  • 772

C# code for Printing & Previewing PDF'S without using Proces

Jul 20 2015 5:44 AM

I have to print and preview the pdf's  separately in 2 different functionalities

i.e without using the 

System.Diagnostics.Process.Start(@filePath); code . As this code is not acceptable by our security platform scan.kindly help..

below is the code

private void PreviewFile(byte[] blobData, string fileName)

{

if (blobData != null)

{

string filePath;

PDFPreviewHandler pdf = new PDFPreviewHandler();

 

string tempDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Template");

if (!Directory.Exists(tempDirectory))

Directory.CreateDirectory(tempDirectory);

filePath = Path.Combine(tempDirectory, fileName);

try

{

FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

bool isfile = false;


fileStream.Write(blobData, 0, blobData.GetUpperBound(0));

fileStream.Flush();

fileStream.Close();

fileStream.Dispose();

//Displaying the file

if (File.Exists(@filePath))

{

isfile = true;

}

if (isfile && File.Exists(@filePath))

System.IO.File.OpenRead(filePath);

wb1.Navigate(@filePath);

// byte[] byteArray = System.IO.File.ReadAllBytes(@filePath);

// System.Diagnostics.Process.Start(@filePath);

}

              


 




































 



 

System.Diagnostics.Process.Start(@filePath);






 

 


Answers (3)