public bool Open(AxHwpCtrl hwp) { if (hwp.Open(hwpPath, "HWP", "")) { var tmpName = Path.GetTempFileName(); if (hwp.SaveAs(tmpName, "HWPX", "")) { hwp.Clear("1"); // hwpDiscard: Discard document changes. xPath = tmpName; xDoc = new HwpxDocument(xPath); if (xDoc.Open()) { State = HwpState.HmlReady; return(true); } else { State = HwpState.ErrHmlLoadFail; return(false); } } else { State = HwpState.ErrHmlCreateFail; return(false); } } else { State = HwpState.ErrOpenFail; return(false); } }
private void convert_thread(string[] paths, bool bUseCurrentPath, string strSavePath) { AxHwpCtrl temp_hwp = new AxHwpCtrl(); temp_hwp.CreateControl(); bool bReg = temp_hwp.RegisterModule("FilePathCheckDLL", "FilePathCheckerModuleExample"); int nRow = 0; int nConverted = 0; add_log("PDF 변환을 시작합니다. 잠시 기다려 주세요......"); foreach (string file_path in paths) { string file_ext = System.IO.Path.GetExtension(file_path).ToUpper(); string file_type = ""; if (file_ext.Equals(".HWP")) { file_type = "HWP"; } else if (file_ext.Equals(".TXT")) { file_type = "UNICODE"; } if (temp_hwp.Open(file_path, file_type, "")) { show_convert_state(nRow, "변환중"); string pdf_path = ""; if (bUseCurrentPath == true) { pdf_path = System.IO.Path.GetDirectoryName(file_path) + "\\" + System.IO.Path.GetFileNameWithoutExtension(file_path) + ".PDF"; } else { pdf_path = strSavePath + "\\" + System.IO.Path.GetFileNameWithoutExtension(file_path) + ".PDF"; } if (temp_hwp.SaveAs(pdf_path, "PDF", "")) { show_convert_state(nRow, "완료"); nConverted++; } else { show_convert_state(nRow, "열기실패"); } } else { show_convert_state(nRow, "변환실패"); } temp_hwp.Clear(); nRow++; if (st_bConverting == false) { add_log("변환 작업을 중단합니다."); break; } } add_log(String.Format("{0}개 파일 중 {1}개 파일을 PDF로 변환하였습니다.", paths.Length, nConverted)); st_bConverting = false; enable_controls(true); }