The C# sample provided in this section uses the Muhimbi PDF Converter Services Online to convert (if needed) and merge multiple files and HTML into a single PDF. This is somewhat similar to our other merge example with the main differentiator being that in this example we only pass in the (SharePoint Online) paths to the files to convert and merge. This makes it easier to merge a large number of files in a single operation.
Before executing the example, please update Program.cs and make the following changes:
- API Key: The key associated with your subscription, see below for details.
- SiteUrl: The URL to the SharePoint Online Site Collection where the files are located.
- SourceFileUrl: A list of (paths to) files to convert, see inline documentation.
- DestinationFileUrl: The SharePoint path and file name to write the merged file to.
- Credentials: If the Muhimbi App is NOT installed on the site collection then pass in a username and password. Use App Passwords in environments that use Multi Factor Authentication.
Additional sample code to convert, merge, watermark, secure and OCR files can be found here.
Full details about the merge_to_pdf
method, fields and properties can be found in the Wiki.
Download the sample code using a method of your choice. Some examples are provided below.
-
Git: Clone the entire repository to your system. You can find the examples under the
clients/v1/csharp/samples
folder.git clone https://github.com/Muhimbi/PDF-Converter-Services-Online
-
SVN: A common trick to download only part of a Git repository is to use
svn
. Download only the C# client and sample code using the following command.svn export https://github.com/Muhimbi/PDF-Converter-Services-Online/trunk/clients/v1/csharp
-
ZIP: Download a ZIP archive of the entire repository. Once downloaded, you can find the examples under the
clients/v1/csharp/samples
folder.
In order to successfully execute the sample code, make sure you have a valid subscription, either a full one or the 30 day trial.
❗ Each subscription comes with a unique api_key
. Before executing the sample, please insert your key in the code. ❗
Make sure the prerequisites are in place. The sample code expects the client libraries to be present under ../../client/bin
.
There are many ways to compile C# code. Use one of the following:
-
msbuild: Execute
build_and_run.bat
to compile the code (using the stock .NET 4 compiler) and run the example. To use a different version ofmsbuild
, change the path in the batch file. -
xbuild (mono): Execute
build_and_run.sh
on a system with Mono 3 or later installed. This will compile the sample and run it. -
Visual Studio: Open
sample.csproj
in Visual Studio and use CTRL-F5 to build and execute the sample.
Once the sample has completed the merge process, the generated PDF can be found in the specified location in SharePoint Online.
If you have any questions or comments then please contact our friendly support desk.