How do I resolve "Failed to initialize OLE libraries" in my Office to PDF / XPS converter?

136 views
Skip to first unread message

Support

unread,
Jul 26, 2011, 3:52:05 PM7/26/11
to PDFTron PDFNet SDK
Q: I have the 'convert to xps' working great, but I also need to
convert Word (and MS Office files) to PDF. I'm stuck on the following
error:

Exception:
Message: An error occurred while converting the file.
Detailed error:
Failed to initialize OLE libraries
Conditional expression: false
Function : trn::PDF::Convert::ToPdf

Any hints on what the issue might be?

It is a simple function and the printer is installed:

PDFDoc doc = new PDFDoc();

{
string testfile = @"E:
\test.docx";

//save file to disk - the
pdftron convert.topdf function does not accept a stream
FileStream fileStream = new
FileStream(testfile,FileMode.Create,FileAccess.ReadWrite);
fileStream.Write(binFile,
0,binFile.Length);

try
{
if
(pdftron.PDF.Convert.RequiresPrinter(testfile))
{

Console.WriteLine("Printing file" );
}
//Convert from disk

pdftron.PDF.Convert.ToPdf(doc, testfile);
}
catch (PDFNetException e)
{
Console.WriteLine(e);
}
}

Before I execute it I check for the printer:

//check for pdfnet virtual printer
Boolean uninstallPrinterWhenDone = false;
if (pdftron.PDF.Convert.Printer.IsInstalled("PDFTron Creator"))
{
pdftron.PDF.Convert.Printer.SetPrinterName("PDFTron Creator");
}
if (!pdftron.PDF.Convert.Printer.IsInstalled())
{
try
{
Console.WriteLine("Installing printer (requires
administrator)");
pdftron.PDF.Convert.Printer.Install();
Console.WriteLine("Installed printer " +
pdftron.PDF.Convert.Printer.GetPrinterName());
// the function ConvertToXpsFromFile may require
the printer so leave it installed
// uninstallPrinterWhenDone = true;
}
catch (PDFNetException e)
{
Console.WriteLine("ERROR: Unable to install
printer");
Console.WriteLine(e.Message);
}
}


--------------------

A: As a first step, are you able to run Convert or SilverDox convert
sample? If you do not encounter any issues when running these samples
it is possible that your solution is missing correct "app.manifest".
In this case you can copy the "app.manifest" to your project.

Also do you have MS Office installed on your system? If you have MS
Office installed, you _do not_ need to install or use the print driver
(which requires extra permissions).

Reply all
Reply to author
Forward
0 new messages