public void KompasConvertToPdf(List <SpcObject> listSpcObject) { if (listSpcObject == null) { return; } foreach (var spcObject in listSpcObject) { var doc = spcObject.Documents.FirstOrDefault(f => IsFileExtension(f.FileName, SOURCE_DOC_EXT)); if (doc == null) { continue; } var fileName = doc.FileName; if (!File.Exists(fileName)) { continue; } var pdfFile = Path.GetTempFileName() + PDF_EXT; var isConvert = _komaps.ConvertToPdf(fileName, pdfFile, out var message); if (!isConvert) { continue; } spcObject.PreviewDocument = pdfFile; } }
public void TestConvertToPdfFile() { using (var kompas = new KomapsShell()) { const string path = @"\Spc.spw"; kompas.InitKompas(out var result); kompas.ConvertToPdf(StartupPath + path, StartupPath + @"\spc.pdf", out result); kompas.ExitKompas(); Assert.IsTrue(string.IsNullOrEmpty(result)); } Assert.IsTrue(File.Exists(StartupPath + @"\spc.pdf"), "Pdf file not found"); }