SoFunction
Updated on 2025-03-06

Example of method to implement WPS file to PDF format in C#

This article describes the method of implementing WPS file to PDF format in C#. Share it for your reference, as follows:

Here we mainly use C# to convert wps files into PDF. You need to install WPS in advance and add references to the programusing ;The specific source code is as follows:

using System;
using ;
using ;
using ;
using ;
using ;
namespace 
{
 class WpsToPdf : IDisposable
 {
 dynamic wps;
 public WpsToPdf()
 {
  // Create a wps instance and install wps in advance  Type type = ("");
  wps = (type);
 }
 /// <summary>
 /// Download the file according to the path on the server /// </summary>
 /// <param name="wpsFilename">Wps file path</param> /// <param name="pdfFilename">Pdf file path</param> /// &lt;returns&gt;&lt;/returns&gt;
 public void ToPdf(string wpsFilename, string pdfFilename = null)
 {
  if (wpsFilename == null)
  {
  throw new ArgumentNullException("wpsFilename"); 
  }
  if (pdfFilename == null)
  {
  pdfFilename = (wpsFilename, "pdf");
  }
  ((@"Converting [{0}] -&gt; [{1}]", wpsFilename, pdfFilename));
  //Use wps to open word without displaying the interface  dynamic doc = (wpsFilename, Visible: false);
  //doc to pdf  (pdfFilename, );
  ();
 }
 public void Dispose()
 {
  if (wps != null) { (); }
 }
 }
}

For more information about C# related content, please check out the topic of this site:Summary of common techniques for C# file operation》、《Summary of C# traversal algorithm and skills》、《Summary of thread usage techniques for C# programming》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《C# data structure and algorithm tutorial"and"Introduction to C# object-oriented programming tutorial

I hope this article will be helpful to everyone's C# programming.