'Ole'에 해당되는 글 1건
- 2013.07.24 Convert File Format Using OLE API
<html>
<head>
<script language="javascript">
var vHwpCtrl;
function PDF_Print()
{
var app = new ActiveXObject("AcroExch.App");
var doc = new ActiveXObject("AcroExch.PDDoc");
doc.open("c:\\Docs\\01\\TestPdf.pdf");
var jso = doc.GetJSObject(); // retun javascript object (only used by javascript)
jso.addWatermarkFromText("aa");
var avDoc = doc.OpenAVDoc("print"); //print pdf file
avDoc.PrintPages(0, 1, 2, 0, 0);
}
function WORD_TO_PDF()
{
var wdExportFormatPDF= 17;
var wordApp = new ActiveXObject("Word.Application");
var wordDocs = wordApp.Documents;
var wordDoc = wordDocs.Open("d:\\test\\TestDoc.doc");
wordDoc.ExportAsFixedFormat("d:\\test\\TestDoc.pdf", wdExportFormatPDF);
}
function EXCEL_TO_PDF()
{
var xlTypePDF = 0;
var excelApp = new ActiveXObject("Excel.Application");
var excelWorkBooks = excelApp.WorkBooks;
var excelWorkBook = excelWorkBooks.Open("d:\\test\\TestXls.xls");
excelWorkBook.ExportAsFixedFormat(xlTypePDF, "d:\\test\\TestXls.pdf");;;
}
function PPT_TO_PDF()
{
var ppFixedFormatTypePDF = 2;
var ppFixedFormatIntentPrint = 2;
var ppSaveAsPDF = 32;
var ppSaveAsPNG = 18;
var pptApp = new ActiveXObject("PowerPoint.Application");
var pptPresentations = pptApp.Presentations;
var pptPresentation = pptPresentations.Open("d:\\test\\TestPpt.ppt");
pptPresentation.SaveAs("d:\\test\\TestPpt.pdf", ppSaveAsPDF ); //convert pdf
pptPresentation.SaveAs("d:\\test\\TestPpt.png", ppSaveAsPNG ); //convert image
//pptPresentation.ExportAsFixedFormat("d:\\test\\TestPpt.pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint ); // not working, not find the cause.
}
function HWP_PRINT()
{
hwpCtrl.Open("d:\\test\\TestHwp.hwp");
var vPrintAct = hwpCtrl.CreateAction("Print");
var vPrintSet = vPrintAct.CreateSet();
var vWaterMarkSet = vPrintSet.CreateItemSet("PrintWatermark", "PrintWatermark");
vPrintAct.GetDefault(vPrintSet);
vPrintSet.SetItem("Device", 0);
vWaterMarkSet.SetItem("String" , "bdc");
vPrintAct.Execute(vPrintSet);
}
</script>
</head>
<body onload >
<form name = "HwpControl">
<input type="button" value='PDF' name="job" onclick='PDF_Print()' >
<input type="button" value='WORD' name="job" onclick='WORD_TO_PDF()' >
<input type="button" value='EXCEL' name="job" onclick='EXCEL_TO_PDF()' >
<input type="button" value='PPT' name="job" onclick='PPT_TO_PDF()' >
<input type="button" value='HWP' name="job" onclick='HWP_PRINT()' >
</form>
<object id=hwpCtrl style="left: 0px; top: 0px" height=80% width=80% align=center classid='CLSID:BD9C32DE-3155-4691-8972-097D53B10052' / >
</body>
</html>