Convert Word to PDF in background process either via c#

Below are the  c# code that works with UI thread.

Few seconds answer here Open up as well as tweak Word File says Microsoft carries out not assist unattended autmation by doing this. It likewise proposes using​​

I have actually found a lot of examples internet regarding transforming word (. docx) file to.pdf in c#.

word = new Microsoft.Office.Interop.Word.Application();


            word.Visible = false;
            word.ScreenUpdating = false;
            doc = word.Documents.Open(wordDocPath);
            pdfPath = wordDocPath.Replace(".docx", ".pdf");

                        OptimizeFor: Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
                        BitmapMissingFonts: true, DocStructureTags: false);

            ((_Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);

It works fine when I fly UI string. The minute I execute it on history method. at that point it fails. Is actually there some method to convert Word to PDF using background procedure completion?

from c# it tosses Things endorsement certainly not prepared to a case of the item inaccuracy. additionally when evaluated making use of python, I had the ability to no in on the product line where it breaks, it falls short to boot up document things at below collection doc = word.Documents.Open( wordDocPath); as a result of operating on history procedure without UI string.

I have actually only confirmed that this script functions – likewise coming from a task/ background procedure:

The code runs it seems to be to open up a word occasion to monitor, it did open up a package as well as improvement bar just before I threaded it.

Am certainly not aiming to make use of any kind of 3rd event tools, simply word as from articles on the web site Word is the most ideal at sale.

Am attempting to utlise the processor through running greater than 1 thread and also hasten turning 30000 doctor reports.

Although this is not a cost-free program, yet it deals with history process. It could be easily ported to c# as well, as it is a dll.

When it opens up the Word file its own actually opening up word. before it was simply a conserving PDF progress box

Are actually brand new to threading and have actually begun a 2 strings application, it manages a fundamental Doc to PDF sale approach. The client has actually Word 2003 documents to convert.

You are still opening Word, you simply don’t find the home window. Don’t perform that. Using various strings isn’t mosting likely to help you at all considering that the single treatment will must serialize demands from the strings and also might find yourself deadlocking. Worse, unless you really know COM interop, you can spawn new Word occasions for every file up until the hosting server lacks mind. Use a collection to develop PDF reports directly if you don’t in fact really want the Word files. Even when you do, you still need to use a library for this

Leave a Reply

Your email address will not be published. Required fields are marked *