2016-06-07 6 views
2

Ich versuche, HTML-Datei in MS-Word-Datei (docx) zu konvertieren. Mit Microsoft.Office.Interop.Word kann ich von HTML zu Word konvertieren, aber die Schriftgröße ist nicht gleich für beide HTML-und Word-Format der Datei. Welche Formatierung (Schriftgröße) ich in HTML gemacht habe, ist in Word-Datei verloren. Kann mir jemand helfen, die gleiche Schriftgröße beizubehalten. HierSchriftgröße ist nicht gleich, wenn HTML in Word konvertiert wird mit Microsoft.Office.Interop.Word

ist der Code:

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

wordDoc = wordApp.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 = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault; 

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); 

Dank!

Antwort

0

diesen Code verwenden

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:\\page.html"; 
      Object confirmconversion = System.Reflection.Missing.Value; 
      Object readOnly = false; 
      Object saveto = "c:\\doc.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); 
zu konvertieren
Verwandte Themen