2
A
回答
4
我能夠保存的FlowDocument內容.DOCX和使用的Microsoft.Office.Interop.Word
using moiw = Microsoft.Office.Interop.Word;
public static void WordToPDF(string docFileName)
{
// Create a new Microsoft Word application object
moiw.Application word = new moiw.Application();
// C# doesn't have optional arguments so we'll need a dummy value
object oMissing = Missing.Value;
// Get a Word file
FileInfo wordFile = new FileInfo(docFileName);
word.Visible = false;
word.ScreenUpdating = false;
// Cast as Object for word Open method
Object filename = (Object)wordFile.FullName;
// Use the dummy value as a placeholder for optional arguments
moiw.Document doc = word.Documents.Open(ref filename, 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, ref oMissing, ref oMissing);
doc.Activate();
object outputFileName = wordFile.FullName.Replace(".docx", ".pdf");
object fileFormat = moiw.WdSaveFormat.wdFormatPDF;
// Save document into PDF Format
doc.SaveAs(ref outputFileName,
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 oMissing, ref oMissing, ref oMissing);
// Close the Word document, but leave the Word application open.
// doc has to be cast to type _Document so that it will find the
// correct Close method.
object saveChanges = moiw.WdSaveOptions.wdDoNotSaveChanges;
((moiw._Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
doc = null;
// word has to be cast to type _Application so that it will find
// the correct Quit method.
((moiw._Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);
word = null;
}
0
我們已經爲這個優雅的解決方案稱爲NiPDF
。這是一個純粹的.NET
組件。
下面是一個轉換WPF視覺到PDF的例子:http://nixps.com/nipdf/example0001.html 同樣可以將的FlowDocument轉換爲XPS,並使用我們的NiPDF控制去PDF。
+0
將其轉換爲PDF解決我的問題,它很酷,但它是一個第三方控制 – xscape 2011-03-17 09:33:22
相關問題
- 1. rest to Latex to PDF
- 2. svg to html to pdf conversion
- 3. powershell word to pdf
- 4. perl excel to pdf
- 5. PDF to Image - Magick ++
- 6. .eml to .pdf API
- 7. pyplot to 3d pdf
- 8. itext - pdf to html
- 9. Word Automation to pdf
- 10. 「Publish」to pdf
- 11. javascript jsgantt to PDF
- 12. .cdr to pdf converion
- 13. Convertir UITableView to PDF
- 14. Markdown to PDF
- 15. Asp.net webform to pdf
- 16. PDF to Apple Newsstand
- 17. Itext Ilist to pdf
- 18. Joomla content to pdf
- 19. HTML to PDF Rails
- 20. HTML5 canvas to PDF
- 21. itextsharp postscript to PDF
- 22. dynamic PDF v/s HTML to PDF
- 23. ImageMagick pdf to black and white pdf
- 24. PDF to PDF/A-2b without dUseCIEColor
- 25. Active Admin view to PDF
- 26. Html to PDF ITextSharp Image
- 27. Imagemagick convert pdf to png
- 28. PDF to XPS with java
- 29. .doc to pdf using python
- 30. Bookmarklet to unframe PDF(IEEExplore)
你是如何將FlowDocument內容轉換爲docx的? – SemMike 2012-05-07 05:06:02