Looking for sample code for doing the conversion from pdf to xod totally in memory and returning the XOD in a byte array. Currently in my web service I'm saving the pdf I retrieve from my DB, then using docpub to convert the file, reading the xod result back and returning that in my web service. I know this is completely ineffient, but I can find sample code for doing it in memory. Below is the code I'm currently using:
if (attachTable.Rows.Count >= 1)
{
DataRow row = attachTable.Rows[0];
byte[] fileData = new byte[0];
fileData = (byte[])row["filedata"];
string name = row["filename"].ToString();
name = col + "-" + rev.ToString() + "-" + name;
int arraysize = fileData.GetUpperBound(0);
string uploadFolder = @"D:\webservices\3x3PM\wwwstore";
if (!fileData.IsNull())
{
name = name.Replace(" ", "");
string filePath = Path.Combine(uploadFolder, name);
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(fileData, 0, arraysize);
fs.Close();
LaunchConverterApp(filePath, filePath.Replace(".pdf", ".xod"));
result.File = System.IO.File.ReadAllBytes(filePath.Replace(".pdf", ".xod"));
}
}
public void LaunchConverterApp(string input, string output)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = @"C:\docpub32.exe";
startInfo.WindowStyle =
ProcessWindowStyle.Normal;
startInfo.Arguments = input + @" -f xod -o " + @"D:\webservices\3x3pm\wwwstore --noprompt";
try
{
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
}
}