Viewing a document in memory with WPF
I have to create a tool that displays documents to a user with a memorystream. I decided to try this with wpf, but i was having a lot of trouble with it.
This site was giving me the idea on how to view xps documents through a memorystream, but I was getting a corrupted file error on Package.Open when i tried to read a .doc or .pdf file. The files that I'll be needing to read are mostly .pdf files.
I don't want to make the file available to the users, which is why i'm not just quickly writing the data from it's bytes to a an actual file, and just reading that. I've ended up just deciding to make a compromise with that, and use isolated storage to write the file to, and purge it when the app is done. Feels like a cheat, but I'm not getting many better results.
I integrated a webbrowser with my WPF code using windowsformsintegration:
<WindowsFormsHost>
<winfrm:WebBrowser x:Name="wbBrow"></winfrm:WebBrowser>
</WindowsFormsHost>
I tried playing with the 'documentstream' option on the webbrowser control, but that doesn't work for .pdf files, it just shows gibberish. I also tried using adobe's own COM control, but there is only a "LoadFile" option, which doesn't give me any extra help.
One of the real annoying things about this project is that the pdf file is password protected, and i have no idea how avoid getting the user to type in the password by doing it programmatically.
This site was giving me the idea on how to view xps documents through a memorystream, but I was getting a corrupted file error on Package.Open when i tried to read a .doc or .pdf file. The files that I'll be needing to read are mostly .pdf files.
I don't want to make the file available to the users, which is why i'm not just quickly writing the data from it's bytes to a an actual file, and just reading that. I've ended up just deciding to make a compromise with that, and use isolated storage to write the file to, and purge it when the app is done. Feels like a cheat, but I'm not getting many better results.
I integrated a webbrowser with my WPF code using windowsformsintegration:
<WindowsFormsHost>
<winfrm:WebBrowser x:Name="wbBrow"></winfrm:WebBrowser>
</WindowsFormsHost>
I tried playing with the 'documentstream' option on the webbrowser control, but that doesn't work for .pdf files, it just shows gibberish. I also tried using adobe's own COM control, but there is only a "LoadFile" option, which doesn't give me any extra help.
One of the real annoying things about this project is that the pdf file is password protected, and i have no idea how avoid getting the user to type in the password by doing it programmatically.
Labels: adobe, document, memorystream, pdf, webbrowser, WPF, XPS
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home