개발/C#

C# Html to pdf 변환

FA1976 2018. 11. 20. 09:13
반응형

            //HtmlConverter.ConvertToPdf(    new FileInfo(@"C:\Temp\sample_utf8.html"),    new FileInfo(@"C:\Temp\sample.pdf") );

            Microsoft.Office.Interop.Word.Application word =  new Microsoft.Office.Interop.Word.Application();

            Microsoft.Office.Interop.Word.Document wordDoc =  new Microsoft.Office.Interop.Word.Document();

            Object oMissing = System.Reflection.Missing.Value;

            wordDoc = word.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            word.Visible = false;

            Object filepath = @"C:\Temp\sample.html";

            Object confirmconversion = System.Reflection.Missing.Value;

            Object readOnly = false;

            Object saveto = @"C:\Temp\sample.pdf";

            Object oallowsubstitution = System.Reflection.Missing.Value;


            wordDoc = word.Documents.Open(ref filepath, ref confirmconversion,

                                            ref readOnly, ref oMissing,

                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing,

                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing,

                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            object fileFormat = WdSaveFormat.wdFormatPDF;

            wordDoc.SaveAs(ref saveto, ref fileFormat, ref oMissing, ref oMissing, ref oMissing,

                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,

                                ref oMissing, ref oMissing, ref oMissing, ref oallowsubstitution, ref oMissing,

                                ref oMissing);


반응형