/// <summary> /// Copy file and take local path into consideration /// </summary> /// <param name="file"></param> /// <param name="target"></param> private void CopyEmbeddedFile(string file, string target) { string fileName = HoUtil.GetFilePath("Linked File", file); if (IsFileToProcess(fileName)) { DirFiles.FileCopy(fileName, target); } }
/// <summary> /// Export Embedded Files. Make XHTML and copy the file. Consider the EA local path to access the file /// </summary> /// <param name="file"></param> /// <param name="xhtml"></param> /// <returns></returns> private string ExportEmbeddedFiles(File file, string xhtml) { string defaultText = Path.GetFileName(file.Name); string fileName = (Path.GetFileName(file.Name)); // Check if file is to process string fullFileName = HoUtil.GetFilePath("Linked File", file.Name); if (!IsFileToProcess(fullFileName)) { return(""); } // copy embedded file CopyEmbeddedFile(fullFileName, Path.Combine(_dirFilesRoot, _embeddedFiles)); string imagePath; string mimeType; switch (Path.GetExtension(file.Name)) { case ".pdf": mimeType = "application/pdf"; imagePath = "application-pdf.png"; break; case ".doc": imagePath = "application-msword.png"; mimeType = "application/msword"; break; case ".docx": imagePath = "application-msword.png"; mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case ".xls": imagePath = "application-vnd.ms-excel.png"; mimeType = "application/vnd.ms-excel"; break; case ".xlsx": imagePath = "application-vnd.ms-excel.png"; mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; case ".ppt": imagePath = "application-vnd.ms-powerpoint.png"; mimeType = "application/vnd.ms-powerpoint"; break; case "pptx": imagePath = "application-vnd.ms-powerpoint.png"; mimeType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; break; default: mimeType = "application/pdf"; imagePath = @"text-x-java.png"; defaultText = @"{defaultText}, not supported mime type/file type"; break; } xhtml = xhtml + $@" <div>{fileName}</div> <object data=""{Path.Combine(_embeddedFiles, fileName)}"" type=""{mimeType}""> <object data=""{Path.Combine(_mimeTypeImages, imagePath)}"" type=""image/png"">{defaultText} </object> </object> "; return(xhtml); }