Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Apr 07, 2016 2:09 pm

Hi Team,

We are trying to convert a .Odt file to .pdf via first saving the .odt file as .doc and then opening up the .doc file and save it as .pdf.

But while saving the file as .pdf it is giving error : An unhandled exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll

Additional information: The given key was not present in the dictionary.

We are using Spire.doc version : 5.6.62 and Spire.PDF version : 3.6.260 (Trial one)

Please find the below sample code :

public void generateDoc()
{
string strParth = @"C:\Users\nirad_smart\Downloads\";
string FileName = @"Sample_invoice.odt";
string FileName1 = @"Sample_invoice_doc";
string FileExt = @".doc";
string docfileName = strParth + FileName1 + FileExt;
Stream stream = File.OpenRead(strParth + FileName);
using (Stream file = File.Create(strParth + FileName1 + FileExt))
{
CopyStream(stream, file);
}
stream.Close();

Document doc = new Document();
doc.LoadFromFile(docfileName);
doc.SaveToFile("final.pdf", FileFormat.PDF);

}
/// <summary>
/// Copies the contents of input to output. Doesn't close either stream.
/// </summary>
public static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}

}
}

Can you please help us out here ?

niradsmart
 
Posts: 3
Joined: Thu Apr 07, 2016 2:01 pm

Fri Apr 08, 2016 3:05 am

Hello,

If you need to use Spire.Doc product and Spire.PDF product in same project, we recommend you to get Spire.Doc.dll and Spire.Pdf.dll from Spire.Office package.
At present, the latest version is (Spire.Office Platinum (Hot Fix) Version: 2.13.4). Please try the version.

If there still is the issue after trying, please provide your .odt file to help us investigate it.

Thank you in advance.
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Fri Apr 08, 2016 6:45 am

Hi Caroline,

We are still getting the same error. Tried it by installing Spire.Office Version 2.13.4 nuget package as you suggested.

Please find the attached .odt file to test.

niradsmart
 
Posts: 3
Joined: Thu Apr 07, 2016 2:01 pm

Fri Apr 08, 2016 9:39 am

Hello,

Thanks for the information.
I have reviewed your codes, and the process of odt to doc conversion doesn’t convert .odt to .doc, it is still .odt document. Also, sorry that our product don’t support to manipulate the odt documents at present.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Mon Apr 11, 2016 7:08 am

Hi Caroline,

I don't think that after conversion it still remains .odt

As i have checked on my side and shown in the attached .jpg it converted .odt file to .doc

Can you please check if this thing happens on your side and after successful conversion the .doc is converted to .pdf using spire ?

niradsmart
 
Posts: 3
Joined: Thu Apr 07, 2016 2:01 pm

Mon Apr 11, 2016 9:02 am

Hi,

It only change the file extension, not a real doc document, here is the screenshot for their binary comparison.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Return to Spire.Doc

cron