I'm working on a WinForms C# 3.0 / .NET 3.5 project involving building some canned reports. One of the requirements of the project is to export to PDF format, and currently doing so to disk is working just fine. The question was raised, however, if it's possible to export the file to a stream and open it directly in the native viewer on the client, skipping entirely writing it to disk. I know that this is somewhat possible with ASP.Net through the use of Response.Write() headers and the like, but I need to try to do this with standard WinForms/WPF, and I've exhausted my own ideas for it. Anybody have any insight on how it might be done, if it's possible at all? Or does the file have to be written to disk first, then opened separately?
I think it is important that you ask yourself what you accomplish if you bypass the file system. Writing to a the standard temporary folder is a perfectly acceptable solution. This is typically how browsers let you view media files and pdfs. I would concentrate on writing a nice cleanup function, that removes the temporary file after it has been create. Also what would be the purpose of exporting to PDF if you are not saving the file?
Under Unix / Linux you could have made a named pipe in the file system. This make sense if you have a huge media stream that you want to buffer between applications. In the PDF case you win very little.
Export to a temporary folder. It is Ok.
You will need to write the PDF to a temp directory.
The only way to display a PDF from an in-memory stream is to embed a third-party PDF viewer control
Related
In our application you can import - for instance - a pdf file into the application area. In the popup window where you define the path of the pdf file, you can specify if the original file should be deleted after a successful import or not.
Sometimes a user imports a pdf file, which he has also "open" in an pdf reader (in our case pdf xchange viewer and foxit reader). In this case our application cannot delete the pdf file because it is somehow blocked.
How can I find out - for instance a winapi call? (without trying to delete it or rename it) that the pdf is blocked by a pdf reader?
Thanks alot in advance
Though it is not good to interfere with other programs (just tell your user the file is being used), releasing file locks are a bit difficult.
First, you need to use ZwQuerySystemInformation to obtain a system-wide file handle table (and your program needs SeDebug privilege) and find the file being used.
Use DUPLICATE_CLOSE_SOURCE flag for DuplicateHandle to duplicate and close the file handle.
Or, go into the kernel and use ZwClose or ObDereference functions to close a file.
Still, closing a file outside may crash remote programs and it is against Windows' design principles.
I am a trying to write a hobby project that allows users to package files like pdf (later docx) as executables that can be viewed on other machines without pdf readers. The most common way is to convert it into another format (for which you have an application installed).
I am thinking about creating an ".exe". The idea is to develop a C application that takes pdf file as input and makes the functions calls that a pdf-reader (library not yet decided) makes to "open" & "display" a pdf.
Then I can compile this into an ".exe" that can be run on any PC to display this particular file.
I just wanted to ask you guys if this makes sense or is utterly stupid?
I'm developing a WPF based app in C# and I want to play an h.264/aac encoded mp4 file from a stream source that derives from System.IO.Stream.
I can play videos directly from local files, and from a URL source, but I also need to playback video from a data source that derives from System.IO.Stream. Specifically, I'm using a product from Eldos called Solid File System (http://eldos.com/solfs/) which allows you to create virtual file systems inside a single file. To access data stored inside a SolidFS file they offer SolFSStream which derives from System.IO.Stream.
Does anyone know of a .Net Framework API, or third party API that will allow me to play the video by passing in the stream reference?
My preference would be to copy the files to a temp directory that the application can access, then use a simple to use and robust library to play the file e.g http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.aspx
My reasoning would be that supporting stream may not be the best criterea to choose a third party library to play mp4 files. You need to ensure that the library is robust and easy to integrate with your existing application.
Please note, by referring to the MediaPlayer class I am not saying that this is the most robust library, but it has met my use cases in the past and was easy to integrate with the application.
DirectX had some methods to play custom streams, but I don't know details. Also, we offer OS edition of SolFS for usage scenarios like yours - you can have a virtual disk with OS edition and play from there (and disk access can be restricted to only your application and the player for security).
I used Sphinx4 for some time which really fits my needs. I load a recognizer, pass the audio data to it and use the recognized String in my application.
Right now I'm working on a C application (C++ is unfortunately not an option) where I need something similar and thought that I could use Sphinx3 which is written in C.
The problem is that I don't really know how it is used inside an application and there is no "Hello World"-example as Sphinx4 provides it.
I already compiled and installed sphinxbase and sphinx3 and now I can include the sphinx header files in my application.
Now to my questions:
Is there a "simple" and well documented example application that uses sphinx3 from a C environment?
How can I load up the sphinx3 engine and call a recognizer with my binary audio data?
OR: Do I need to start an application like "sphinx3_decode" and call it from my own application? If so, is there an example application for that?
Thank you in advance!
Best regards,
Robert
It's not recommended to use Sphinx3. From the website:
Sphinx-3 is CMU’s large vocabulary speech recognition system. It’s
older C based decoder that we continue to maintain. It’s planned to
make it obsolete in the future, it’s still most accurate decoder for
large vocabulary tasks. We are using it as a baseline to check the
recognizer accuracy. This decoder is only intended for researchers who
want to evaluate bleeding edge methods in ASR like tree search method.
If you need to use a decoder you should use pocketsphinx. You can find the tutorial and the API documentation on the website
http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx
http://cmusphinx.sourceforge.net/api/pocketsphinx/pocketsphinx_8h.html
I Recently worked on an Intregated Project on Punjabi Language.
Here are some steps that we used...
First we recorded the punjabi audio data in a vaccumed room in 16000 hz sample rate.
Then we took the recorded data and segmented it using Praat Software into small wav and raw files of 2 to 30 sec and saved them in a folder named train.
Then we took a system having Linux ie. Ubuntu and installed the required plug in like autoconfig, automake etc and untarred Sphinx 3 along with 4 packages that are cmuclmtk, pocketsphinx, sphinxbase, sphinxtrain.
Then according to the small wav files we made many files like transcription, dic, phone, filler, file id, ccs etc.
Then we opened the terminal and typed –"sphinx_fe” to check the whether the sphinx is functional or not.
Then we created an folder named “man” and then in terminal wrote its path.
Then we run the command- “sphinxtrain –t man setup”. By running this command an folder named “etc” will be formed in “man” folder containing files “feat_paramas” & ”config”.
Changes were made in the in the config file according to our data.
Then we moved all the files that we created before ie. transcription, dic in the etc folder in that is located in man folder.
Then we placed ‘lang1.sh” script in etc folder and remaining 4 scripts in man folder.
Then we opened the path for etc folder in terminal and run command- “lang1.sh”
Then we run series of commands in terminal – “mfcgen2.sh” then “verify3.sh” then “hmm4.sh” and at last “end-test.sh” to get the final result.
Rest if you have worked on Sphinx 4 then you may know about the files that are mentioned above in the steps. I hope this helps you.
I really want to know what the XAP file on Windows Phone 7 is; how important it is; and how I can create it. Could you help me?
XAP is the application package - it is the distributable unit that allows you to install the application on a device (or emulator). Basically, it is a ZIP file with a different extension. If you change XAP to ZIP, you'll be able to read its contents fairly easy.
The XAP file format was inherited from standard Silverlight, and since WP7 is built around the same fundamental core, the file format remained unchanged.
Here is a pretty good description of what it does (remember, that even though it talks about Silverlight, the same main idea applies to WP7):
http://beyondrelational.com/blogs/dinesh/archive/2010/08/18/what-is-xap-file.aspx
In addition to Dennis' excellent post, one other thing about a XAP file - it's a ZIP file - so if you want to look inside one, then just rename it to .zip and then open it using a normal ZIP browser (e.g Windows explorer)