问题
I am developing a C# WinForms application, and I would like to be able to "preview" various document types within it. That is, when a user selects a filename from a list, it shows below, within the same form, a preview of the selected file. It's a lot like they way Outlook allows you to preview a selected message without double-clicking.
Is there any way to take just a filename and create a control dynamically within my WinForms application that shows the contents of that file?
回答1:
If you want to provide a preview/readonly version of the file types, an idea might be to implement PDF viewing first, this primarily involves converting PDF pages to images and then creating a view for those. Once you have that done (using GhostScript or other commercial components) you can then work on converting other formats to PDF, and use the PDF viewing option, you can probably do most office documents through word automation and text based files could be displayed directly (possibly using a rich text editor for formatted text)
HTH
来源:https://stackoverflow.com/questions/12386701/previewing-documents-word-excel-pdf-text-file-etc-within-c-sharp-winforms