private void InsertWord(string path) { if (isImage == "1") { string tempPdf = tempDir + "\\" + Guid.NewGuid() + ".pdf"; string outDir = tempDir + "\\" + Guid.NewGuid() + "\\"; OfficeBuilder ob = new OfficeBuilder(); ob.Word2PDF(path, tempPdf); PdfToImageBuilder ptib = new PdfToImageBuilder(); ptib.Convert(tempPdf, outDir, "test", PdfToImageBuilder.Definition.One); File.Delete(tempPdf); string[] images = Directory.GetFiles(outDir); foreach (string img in images) { InsertImage(img); File.Delete(img); } Directory.Delete(outDir); } else { object objFalse = false; object confirmConversion = false; object link = false; object attachment = false; word.Selection.InsertFile( path, ref objMissing, ref confirmConversion, ref link, ref attachment ); } }
public void InsertPpt(string path) { string outDir = tempDir + "\\" + Guid.NewGuid(); OfficeBuilder ob = new OfficeBuilder(); ob.PPT2Image(path, outDir); string[] images = Directory.GetFiles(outDir); foreach (string img in images) { InsertImage(img); File.Delete(img); } Directory.Delete(outDir); }
public void InsertExcel(string path) { if (isImage == "1") { string tempPdf = tempDir + "\\" + Guid.NewGuid() + ".pdf"; string outDir = tempDir + "\\" + Guid.NewGuid() + "\\"; OfficeBuilder ob = new OfficeBuilder(); ob.Excel2PDF(path, tempPdf); PdfToImageBuilder ptib = new PdfToImageBuilder(); ptib.Convert(tempPdf, outDir, "test", PdfToImageBuilder.Definition.One); File.Delete(tempPdf); string[] images = Directory.GetFiles(outDir); foreach (string img in images) { InsertImage(img); File.Delete(img); } Directory.Delete(outDir); } else { if (isSheet == "1") { string outDir = tempDir + "\\" + Guid.NewGuid(); OfficeBuilder ob = new OfficeBuilder(); ob.SplitExcel(path, outDir); string[] excels = Directory.GetFiles(outDir); foreach (string e in excels) { AddOLEObject(e); File.Delete(e); } Directory.Delete(outDir); } else { object objPath = path; word.Selection.InlineShapes.AddOLEObject(ref objMissing, ref objPath, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing); } } }