Question:Any easy way to create a PDF document of a word file from desktop application using C++ or C#? Any best practices, please share, list all possible APIs free/paid so that this thread helps C++/C# programmers.
Answer: When you need to create PDF from word from C++/C# by desktop version, maybe you can have a free trial of this software VeryDOC DOC to Any Converter, which is command line version software. And if you need to use API for creating PDF from word, maybe you can have a free trial of those software: VeryPDF Office Document and PDF to HTML5 Slideshow Cloud API, VeryPDF Viewer Cloud API (Online Document / PDF Viewer Cloud API). By those API, you can also run the conversion from C++/C# programmers. Here in VeryDOC, we do not have tutorial for creating PDF from word of API application, please check in VeryPDF knowledge base. In the following part, I will show you how to create PDF from word by desktop application using C++/C#.
Download DOC to Any Converter Command Line
- Please download this software to your computer. As it is command line version software, when downloading finishes, there will be a zip file. Please extract it to some folder then you can call it from MS Dos Window normally.
- When you use this software, please refer to code template of COM version. In the command line zip folder, there is no code template available.
Creating PDF from word using C++/C# programmers.
- Here is code template of creating PDF from word by C#, please have a check.
Please by following steps to call doc2any.exe inside a special user account,
1. Please download and install EXEShell COM Library (freeware) first, and then use the following C# code to run the conversion inside a special user account,
~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Type otype = System.Type.GetTypeFromProgID("exeshell.shell");
Object o = System.Activator.CreateInstance(otype);
otype.InvokeMember("RunCommandLine", System.Reflection.BindingFlags.InvokeMethod, null, o,
new object[] { "UserName", "Password", @"C:\doc2any.exe ""C:\test.doc"" ""C:\out.pdf""" });
otype = null;
}
}
}
~~~~~~~~~~~~~~~~~
Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please by following steps to solve this 1314 Error,
ERROR 1314:
~~~~~~~~~~~~~
1314 A required privilege is not held by the client. ERROR_PRIVILEGE_NOT_HELD
~~~~~~~~~~~~~
By this method, you can create PDF from word by C#. During the using, if you have any question, please contact us as soon as possible.