Path

1
2
3
4
5
6
//sourceFolder  源目录
//destinationFolder 目标目录
private static string basePath = AppDomain.CurrentDomain.BaseDirectory;
string outputFileName = destinationFolder + "\\" + Path.GetFileName(inputFile).Replace(Path.GetExtension(inputFile), ".pdf");
string inputFileFullPath = basePath + sourceFolder + "\\" + inputFile;
string outputFileFullPath = basePath + outputFileName;

ConvertWordToPdf

1
2
Document wordDoc = new Document(inputFileFullPath);
wordDoc.Save(outputFileFullPath, Aspose.Words.SaveFormat.Pdf);

ConvertExcelToPdf

1
2
3
4
5
6
Workbook excel = new Workbook(inputFileFullPath);
PdfSaveOptions saveOptions = new PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
saveOptions.OnePagePerSheet = true;
saveOptions.PrintingPageType = PrintingPageType.Default;
saveOptions.AllColumnsInOnePagePerSheet = true;
excel.Save(outputFileFullPath, saveOptions);

PowerPointToPdf

1
2
Presentation ppt = new Presentation(inputFileFullPath);
ppt.Save(outputFileFullPath, Aspose.Slides.Export.SaveFormat.Pdf);