I am getting the following exception when i try to open a pdf using
pdftron, the code works fine local, but once I run it on the server i
get the exception:
Error Message:
Exception: Message: Unable to open the file Conditional expression:
m_stream
!= NULL Filename : StdFile.cpp Function : trn::Filters::StdFile::InitW
Linenumber : 195
I have tried to open the file two different ways:
Option #1
string PathToFile = @"\\Server\ShareFolder\File.pdf";
System.IO.Stream myFileStream = System.IO.File.Open(PathToFile,
FileMode.Open);
byte[] FileBytes = null;
int out_buffer_size = 0;
pdftron.PDFNet.Initialize(_PDFTronLicenseKey);
using (pdftron.PDF.PDFDoc PDFDocument = new
pdftron.PDF.PDFDoc(myFileStream))
{
PDFDocument.InitSecurityHandler();
//Modification that we do with the file.
PDFDocument.Save(ref FileBytes, ref out_buffer_size,
pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
}
File.WriteAllBytes(PathToFile, FileBytes);
pdftron.PDFNet.Terminate();
Option #2
string PathToFile = @"\\Server\ShareFolder\File.pdf";
byte[] ReadedDocumentBytes = System.IO.File.ReadAllBytes(PathToFile);
byte[] FileBytes = null;
int out_buffer_size = 0;
pdftron.PDFNet.Initialize(_PDFTronLicenseKey);
using (pdftron.PDF.PDFDoc PDFDocument = new
pdftron.PDF.PDFDoc(ReadedDocumentBytes, ReadedDocumentBytes.Length))
{
PDFDocument.InitSecurityHandler();
//Modification that we do with the file.
PDFDocument.Save(ref FileBytes, ref out_buffer_size,
pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
}
File.WriteAllBytes(PathToFile, FileBytes);
pdftron.PDFNet.Terminate();