이 범주에서는 한글 오토메이션에 대한 다른 사용자의 기술 지원을 제공받을 수 있습니다.
지난 번 (C# 라이브러리 형식 hwp to pdf 개발 - jerry 님의 게시물 #7) 글에서 작성한 소스를 가지고 hwp to pdf 기능을 만들어서 배포하여 사용 중인데 특정 PC에서만 printAction에 각 item을 setting 하고 난 후 printAct를 실행시키는 구문(printAct.Execute)에서 Exception이 발생하지 않았는데 file이 존재하지 않고 로직이 마무리되는 현상이 있습니다.
이 문제는 모든 PC에서 발생하지 않고 특정PC에서만 확인되었습니다.
아래 작성한 소스를 첨부해두었으니 참고 부탁드립니다.
수정이 필요한 부분이 있을까요?
private static void ConvertHwpToPdf(string inputHwpPath, string outputPdfPath, ref string code)
{
try
{
HwpObject hwp = new HwpObject();
hwp.RegisterModule("FilePathCheckDLL", "FilePathCheckerModuleExample");
bool opend = hwp.Open(inputHwpPath, "", "forceopen:True;suspendpassword:True;versionwarning:False");
if (!opend)
{
Console.WriteLine("한글 파일이 암호화 되어있습니다.");
code = "3000";
}
else
{
Console.WriteLine("read hwp file");
Console.WriteLine("set hwp action");
IDHwpAction fileAct = (IDHwpAction)hwp.CreateAction("TablePropertyDialog");
IDHwpParameterSet fileSet = (IDHwpParameterSet)fileAct.CreateSet();
fileAct.GetDefault(fileSet);
fileSet.SetItem("TreatAsChar", 1);
fileSet.SetItem("Shapetype", 1);
fileAct.Execute(fileSet);
Console.WriteLine("finish set action");
Console.WriteLine("set hwp print action");
IDHwpAction printAct = (IDHwpAction)hwp.CreateAction("Print");
IDHwpParameterSet printSet = (IDHwpParameterSet)printAct.CreateSet();
printAct.GetDefault(printSet);
printSet.SetItem("PrintMethod", "");
printSet.SetItem("ReverseOrder", false);
printSet.SetItem("Pause", false);
printSet.SetItem("FileName", outputPdfPath);
printSet.SetItem("Device", 3);
Console.WriteLine("finish set print action");
bool result = printAct.Execute(printSet);
Console.WriteLine("sucess convert file");
FileInfo pdfFile = new FileInfo(outputPdfPath);
Console.WriteLine("file is created?:" + pdfFile.Exists);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
code = "3099";
}
}