Convert .msg to .pdf programmatically in C# - c#

I've been trying to convert a large batch of .msg files into .pdf. So far, I've been able to leverage the Universal Document Converter and its libraries, but there's an issue: because it's basically a printer, it pops up a small dialogue box in the background between the conversion of each file, momentarily holding up the system.
I need this to be completely set-and-forget, running silently in the background. I have upwards of 3,600 messages to convert at once, and this happens at least weekly.
I've utilized the PDFsharp libraries before, but I'm still really new to them. Is it possible PDFsharp can do this, without the annoying dialogue boxes?
Any help would be greatly appreciated.

Actually in the most recent version of Universal Document Converter it is possible to get rid of that dialogue:
1) open UDC preferences window and go to "Advanced" section
2) Uncheck "Show progress window while processing" feature
3) Go to "Output location" section and check "Use predefined location and file name"
By the way, I advise you to try use FolderMill software. It works by monitoring hot folder. So you just copy source MSG files to the "Hot Folder" FolderMill monitors. And it will automatically convert all incoming files to PDF with no user interaction.

Related

How to disable download option of pdf file in c# ?

How to disable the pdf Toolbar because I don't want to give the download option to the pdf viewers.
I have used Iframe for showing Pdf File please find the following code
<iframe ID="iFrame2" runat="server" align="bottom" frameborder="2" name="iframe1" height="500" width="600" src="~/pdffiles/example.pdf"></iframe>
Please help me to disable the download option using c#.
Thanks
You cant. It is a browser feature which means you have no control over it.
You can use third party tools like Google Document Viewer or change the format of your document to an image.
Google Document Viewer
If you want to avoid that an end user saves a PDF document, you are asking something that is impossible. The only way to avoid that an end user doesn't have a copy of the PDF is by not sending him the PDF. A PDF can't be opened in Adobe Reader without having the actual bytes on the disk. Even if you would disable saving (for instance in the context of a web application), you'd always find the PDF somewhere in the temp files and people would be able to copy that file as many times as they want.
Trying to hide the toolbar (a viewer preference) doesn't make sense. Whether or not this viewer preference will be respected entirely depends on the PDF viewer. For instance: in Adobe Reader X and later, you have a special widget (HUD or Heads Up Display) that appears when you hover over the document. This widget allows users to save the document.
Let me quote Adobe:
the "Heads Up Display" (HUD) is not customizable. There are no APIs to
HUD. You can’t use JavaScript to enter Read Mode, exit Read Mode or
detect that the document is in Read Mode. Though it might seem like
it, this wasn’t an oversight. There are some very sound engineering
reasons why this is the case but I won’t go into those here.
Even with Adobe Reader 9, hiding the toolbar isn't sufficient: if the user chooses the appropriate menu item or hits the appropriate "hot key", the toolbar would appear and they could happily click the Save button. In addition, they could have right-clicked and chosen "Save" as well.
In short, you're asking the wrong question (and that probably explains the downvotes given by several people).

Print command in EPPlus?

I'm using EPPLUS to allow users to download data to Excel.
However, I'd like to add a feature wherein they can just choose to print this data rather than download it. Can we issue a print command from EPPLus?
It is a web app
Ah, so there's the main problem... You know, even if EPPlus had a method for printing, it wouldn't help you, because it would try to trigger a printing dialog on the server-side, but you need to send the file to the client over the internet. So I'm afraid the answer is no, the client surely has to download the file either way to be able to print it.
Furthermore, xlsx can't be that easily opened in the web browser (compared to pdf for instance), so the solution to somehow trigger a printer dialog on the clients pc will be a tiny bit difficult. C# can't trigger anything over the internet with asp.net because of the security problems and I'm not really sure if javascript has enough permissions to open an application for Excel file and start the printing process..
Maybe your solution would be to create a PDF file instead of XLSX, send it to the client as a part of the website/response and use javascript to print the file. PDF can be opened in most browsers nowadays and we have a nice js function printWithDialog(). I believe this doesn't work for xls and it certainly doesn't fulfil your requirement "without download". The client has to have the access to the file before he can print it, you can't overcome this.

How to programmatically convert a pdf file to a text file?

I need to load a pdf file and then convert it to a text file programmatically in order to then parse it.
Another possibility would be to execute the file (execute Adobe Reader, with the pdf file as the argument) and then "send keys" to it to save the file as text.
However, I would prefer not to do it that way (opening the file) but will if that is the only solution. But: is it even possible to do a "send keys" sort of functionality in C#/WPF?
Note: I don't want to buy any custom components, and besides, I'm using Visual Studio 2012 RC in this "home" project, so I don't know if 3rd party components would be compatible anyway.
If you are looking to deploy this application to other users, I would tend to lean towards using one of the many PDF libraries available and process the PDF via code vs. attempting to use Adobe Reader. It will eliminate issues if your users don't have Adobe Reader installed.
Try starting at the link below for some library ideas.
https://stackoverflow.com/questions/373926/lightweight-open-source-pdf-library-in-c
C# PDF Control & Library

How to merge different document types and show as stack in .NET application

Suppose in .NET (don't care what language) I want to show a user a PDF, Word and Excel file together. I am trying to replicate a document process where a user might have a PDF file and he would like to attach a WORD file and an Excel file let's say to make a stack of documents (that I would save in some directory). Then he would like to click on a button and see a stack of these documents in 1 application of some sort.
How can I display the stack of documents WITHOUT first opening WORD, then openinig EXCEL and then openining ADOBE ACROBAT - this would be really annoying for the user. I would like one unified application or some idea to mimic one in .NET that can just show all 3 documents as if they were printed one after the other on paper. (I hope I am explaining this clearly)
The only thing I can think of to do this would be to leverage some sort of PDF conversion process to create one PDF file containing all three of these documents in "printed" (page-by-page) form, and then show that. The one application I can think of that could show all of these files is a web browser with appropriate Office and Acrobat viewer plugins, and you might find it difficult to leverage that, as browser preference and other user OS settings can cause various strategies for application launching to fail.
I would convert the documents in PDF and develop a pdf viewer inside your application.
I would use a ready made library for that, don't reinvent the wheel.
For example: http://www.quickpdflibrary.com/products/quickpdf/index.php

Save All Print Jobs As PDF

The Goal
The company I work for currently uses a black box shipping system. Each morning our shipping manager prints out shipping tickets for his drivers. Using C#, I would like to save a copy of each ticket printed as a PDF. The action of saving to a PDF should be done behind the scenes.
Note: The PDF copy would be in addition to the hard copy, however, I would like to generate the PDF copy when the hard copy is printed (or directly after if I can use the saved print job).
End Result: The manager prints a hard copy and a PDF gets saved to an archive folder without any interaction from the manager.
What I've Tried
I've instructed the printer to "Keep printed documents" after printing. This leaves a .shd and a .spl file in the print spool folder. I've experimented with the PrintDocument class, but I can find no way to instruct a job to reprint (to a PDF driver) using a completed print job.
Question
Is what I'm trying to accomplish possible?
Further Clarification:
In case it wasn't clear, I do not want the manager to print the document a second time to a PDF print driver. On average he must print 60 tickets each morning before he can send his drivers out. I don't want to increase that number to 120 AND force him to type in the file names.
Additionally, the "black box" shipping system includes other modules that run other portions of our manufacturing plant - changing software is not an option.
I suggest you go with an existing solution to problems like this: Use a software that can install virtual printers that print the document on the printers you want. One such software is PrintDistributor. I don't have any experience with this software but the screenshot named "Virtual Printers" looks promising: The second printer is named "Print and save".
There is other software like this, see here.
According to your goal that you don't want to force him to enter file names, You should do this:
Use a PDF Printer software that provides automatic file naming, like these:
PDF Desk
Cute PDF
And tell the manager to print tickets just with that PDF Printer.
Then, write a c# or vb.net application. use FileSystemWatcher to detect if a new file is created in PDFs directory. and when a new PDF is created, print it.
Here are some tutorials that explains how to Print a PDF file in c#:
Print existing PDF (or other files) in C#
Printing PDF documents in C#
Trapping things being sent to the printer can be very tricky.
A simpler way would be to set up a 'pdf printer' using a piece of software such as:
http://www.bullzip.com/products/pdf/info.php
Configure this to output to a specific directory, and then write a windows service to monitor the directory and automatically send PDF files to the physical printer and archive the file off to a network folder.
[and remove the printer driver from his PC so he can't bypass your new system]
Issue two print commands... one to the paper printer, one to the PDF printer.

Categories

Resources