Re the "PDFNet was already initialized...." message. I understand that is what the message is saying - but take a look at my code below (slightly modified version of the original diagnostic project code). I am not initalizing twice.
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
using (var writer = new StringWriter()) {
Console.SetOut(writer);
Console.SetError(writer);
try {
// Print some useful info about IIS...
Console.Out.WriteLine("-------- Server Information --------");
Console.Out.WriteLine("Running IIS: {0}", Request.ServerVariables["SERVER_SOFTWARE"]);
Console.Out.WriteLine("IIS process name: {0}", Process.GetCurrentProcess().ProcessName);
Console.Out.WriteLine("IIS process is running in {0} mode.", Environment.Is64BitProcess ? "64bit" : "32bit");
Console.Out.WriteLine("IIS process is run using credential: {0}", Request.ServerVariables["LOGON_USER"]);
Console.Out.WriteLine("AppPool ID: {0}", Request.ServerVariables["APP_POOL_ID"]);
Console.Out.WriteLine("-------- Running PDFNet --------");
var pdfnetAssembly = System.Reflection.Assembly.GetAssembly(typeof(pdftron.PDFNet));
Console.Out.WriteLine("PDFNet is loaded from: {0}", pdfnetAssembly.CodeBase);
Console.Out.WriteLine("PDFNet is loaded from GAC: {0}", pdfnetAssembly.GlobalAssemblyCache);
Console.Out.WriteLine("Loaded PDFNet version: {0}", pdftron.PDFNet.GetVersion());
//Console.Out.WriteLine("Initializing PDFNet.");
//pdftron.PDFNet.Initialize("");
var loadPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
if (loadPath.StartsWith("file:///")) {
loadPath = loadPath.Substring("file:///".Length);
}
loadPath = Path.GetDirectoryName(loadPath);
var loadFile = Path.Combine(loadPath, "test.pdf");
var outFile = Path.Combine(loadPath, "test.pdf.xod");
try
{
if (File.Exists(outFile))
{
File.Delete(outFile);
}
}
catch { }
Console.Out.WriteLine("Converting \"{0}\" to \"{1}\"", loadFile, outFile);
pdftron.PDF.Convert.ToXod(loadFile, outFile);
Console.Out.WriteLine("Done converting docx!");
loadFile = Path.Combine(loadPath, "test.docx");
outFile = Path.Combine(loadPath, "test.docx.xod");
try
{
if (File.Exists(outFile))
{
File.Delete(outFile);
}
}
catch { }
Console.Out.WriteLine("Converting \"{0}\" to \"{1}\"", loadFile, outFile);
pdftron.PDF.Convert.ToXod(loadFile, outFile);
Console.Out.WriteLine("Done converting docx!");
loadFile = Path.Combine(loadPath, "test.xlsx");
outFile = Path.Combine(loadPath, "test.xlsx.xod");
try {
if (File.Exists(outFile)) {
File.Delete(outFile);
}
}
catch { }
Console.Out.WriteLine("Converting \"{0}\" to \"{1}\"", loadFile, outFile);
pdftron.PDF.Convert.ToXod(loadFile, outFile);
Console.Out.WriteLine("Done converting xlsx!");
pdftron.PDFNet.Terminate();
}
catch (Exception ex) {
writer.WriteLine("Exception: {0}\nStack:\n{1}", ex.Message, ex.StackTrace);
}
writer.Flush();
Response.Write(writer.ToString().Replace("\n", "<br/>"));
}
Response.Flush();
Response.End();
}
}