How to print DOCX/PDF documents unattended? - c#

I am trying to replace an outdated solution which uses Office Interop to create and print Word documents, and export them to PDF. It needs to run unattended on a server, so we want to get rid of our dependency on Interop. I can create the files fine with Open XML SDK but cannot print or export. Is there some way to do this with libraries (free or paid) that does not require having Adobe/MS Office products installed in a server environment? The limits we have to work within will allow me to either use a .NET console application or a PowerShell script.

Related

Netoffice progid not found

I've done find and replace solution in Micorsoft.Office.Interop.Word in asp.net I would like to move this solution on NetOffice in my asp.net server where there is no Microsoft Word. I got error
progid not found
. What I do wrong because on my computer where I have Microsoft Word this code work fine in NetOffice?
Word.Application wordApp = new Word.Application(); <-- here is this error
NetOffice is just a COM Wrapper to the office applications, therefore it requires that you have the office app installed on the machine where your application is running.
i.e. You need to have Microsoft Word installed on any machine that you intend to run an app that uses NetOffice.Word.
If this was a desktop app, all you would have to do, would be to install Word on the machine, but given you want to use office automation from a server, and Microsoft does not recommend it, you should look into other options of interfacing with Word documents directly via OpenXML without having to install Word on the machine.
I'd recommend taking a look at the DocX library:
https://github.com/WordDocX/DocX
As well as the articles below:
How to: Create a word processing document by providing a file name (Open XML SDK)
Edit Word Documents using OpenXML and C# Without Automation/Interop
Your code should work with NetOffice, but you need to add a using statement:
using Word = NetOffice.WordApi;
You also need to disable the setting Embed Interop types for all NetOffice DLL's.

Will I require MS Excel installed on the server if I am generating Excel file using NetOffice?

I am trying out both NetOffice and NPOI for to use in an ASP.NET project.
I am making an ASP.NET web site where on click of a button, I want to generate an Excel file in a password protected state and send it to the client to download it.
But I want to know whether, will I require MS Excel installed on the server?
OR Is there a way where I can make this work on a server where MS Excel is NOT installed?
Also what are other pre-requisites for both these APIS?
I basically have to identify which of these APIs will work for me in a server without Microsoft Excel installed in it.
Please check documentation: http://netoffice.codeplex.com/documentation at question
What do I have to do to deliver my application with NetOffice?
Nothing except copying the needed assemblies to the target system. You don't need a registration or something like that with the exception of COMAddIns. Managed COMAddins generally have to be registered via the .Net Utility RegAsm.exe or the Windows Installer do that or you.

How to create Word document in WinRT

I'm currently developing application using WinRT/C#. It is second version, first was developed on WPF. In application I need to generate some reports and export them into MS Word document.
In first version of application I used MS Office Interop to export reports in MS Word, but in WinRT there is no support of MS Office Interop. Is there any simple way to create MS Word document in WinRT? (I know there are third party libraries like Syncfusion for WinRT but I would prefer to not use them).
You won't be able to use MS Office interop from a Windows Store app. You could use Open XML SDK, though. It is also available on NuGet and seems to be WinRT compatible.
Using it won't be as easy as working with interop classes and you'll only be able to create XML based docx files, not binary doc files. On the other hand your users won't need to have Word installed and they'll be able to open the files in other Office suites like OpenOffice or LibreOffice. There's a set of tutorials available on MSDN to get you started.
There is a free solution that consiste to format your document in rtf.
For this i create a new librairy to help a developper to create a document compatible with word.
you can find this there : https://github.com/crogun/WinRTF-For-WinRT
the code is open source, and you can extend it if you want.

Microsoft.Office.Interop

I am using Microsoft.Office.Interop.Word.dll to create docx file. It works on my local machine, but can you tell me how to use it on server without installing MS-Office or any third party packages? Please suggest to me some third party tool.
Unfortunately, You have to have MS Office on machine that should run application. Other solution for example via XML:
Link
Its much better to use xml access to word documents, especilly on servers. When using iterop services, it creates mess on server - need to install office, then the COM objects are not disposing themselves...
check this: Open XML SDK, use DocumentFormat.OpenXml.dll

using ms office com objects in other systems without have office installed

i wrote a app for reading excel files.i had to add some references to Microsoft office Com Objects.
it worked good in my system,but when i wanted to use it in other system in which does`t had ms office installed ,
i encounter a problem.i also carried dll files that has been added to project . what should i do ?
In order to use the relevant object libraries you'll have to make sure that Office (Excel in your case) is installed on your client machine. If you have the option I'd suggest to switch to the Open Office XML format anyways. I recently had a similar problem with MS Word and the +work to switch to the new format has def. payed of.
Check MS Open XML SDK
Performace++ and not depending on Office installed...
The Office COM objects depend on Office. You should either arrange for Office to be installed on the other systems, or use a component for reading Excel files that doesn't need Excel installed, such as the ODBC Excel driver or a third-party Excel file reader.

Categories