I first do like this with Spire.Doc and it works like a charm :
- Code: Select all
Spire.Doc.Document document = new Spire.Doc.Document();
document.LoadFromFile(path);
string fileName = path.ToLower().Replace(".docx", ".pdf");
document.SaveToFile(fileName, Spire.Doc.FileFormat.PDF);
return fileName;
But when I add the Spire.Pdf licence I encoutered the following exception :
System.TypeLoadException :
Impossible de charger le type 'spr791' à partir de l'assembly 'Spire.Pdf, Version=3.8.121.5040, Culture=neutral, PublicKeyToken=663f351905198cb3'.
First of all why Spire.Pdf is called when I use Spire.Doc ?
So then I try this :
- Code: Select all
Spire.Pdf.PdfDocument docx = new Spire.Pdf.PdfDocument();
docx.LoadFromFile(path);
string fileName = path.ToLower().Replace(".docx", ".pdf");
docx.SaveToFile(fileName, Spire.Pdf.FileFormat.PDF);
return fileName;
And here I have :
System.ArgumentException :
Unsupported load file format!
So, how can I convert a docx to a pdf ?