Click or drag to resize

PdfMergeClient Class

Pdf Merge with SelectPdf Online API.
Inheritance Hierarchy

Namespace:  SelectPdf.Api
Assembly:  SelectPdf.Api (in SelectPdf.Api.dll) Version: 1.4.0
Syntax
public class PdfMergeClient : ApiClient

The PdfMergeClient type exposes the following members.

Constructors
  NameDescription
Public methodPdfMergeClient
Construct the Pdf Merge Client.
Top
Methods
  NameDescription
Public methodaddFile(String)
Add local PDF document to the list of input files.
Public methodaddFile(String, String)
Add local PDF document to the list of input files.
Public methodaddUrlFile(String)
Add remote PDF document to the list of input files.
Public methodaddUrlFile(String, String)
Add remote PDF document to the list of input files.
Public methodgetNumberOfPages
Get the number of pages processed from the PDF document.
Public methodsave
Merge all specified input pdfs and return the resulted PDF.
Public methodsaveAsync
Merge all specified input pdfs and return the resulted PDF. An asynchronous call is used.
Public methodsaveToFile
Merge all specified input pdfs and writes the resulted PDF to a local file.
Public methodsaveToFileAsync
Merge all specified input pdfs and writes the resulted PDF to a local file. An asynchronous call is used.
Public methodsaveToStream
Merge all specified input pdfs and writes the resulted PDF to a specified stream.
Public methodsaveToStreamAsync
Merge all specified input pdfs and writes the resulted PDF to a specified stream. An asynchronous call is used.
Public methodsetCustomParameter
Set a custom parameter. Do not use this method unless advised by SelectPdf.
Public methodsetDocAddCreationDate
Add the date and time when the PDF document was created to the PDF document information. The default value is False.
Public methodsetDocAuthor
Set the name of the PDF document author.
Public methodsetDocKeywords
Set the PDF document keywords.
Public methodsetDocSubject
Set the subject of the PDF document.
Public methodsetDocTitle
Set the PDF document title.
Public methodsetOwnerPassword
Set PDF owner password.
Public methodsetTimeout
Set the maximum amount of time (in seconds) for this job.
Public methodsetUserPassword
Set PDF user password.
Public methodsetViewerCenterWindow
Set a flag specifying whether to position the document's window in the center of the screen. The default value is False.
Public methodsetViewerDisplayDocTitle
Set a flag specifying whether the window's title bar should display the document title taken from document information. The default value is False.
Public methodsetViewerFitWindow
Set a flag specifying whether to resize the document's window to fit the size of the first displayed page. The default value is False.
Public methodsetViewerHideMenuBar
Set a flag specifying whether to hide the pdf viewer application's menu bar when the document is active. The default value is False.
Public methodsetViewerHideToolbar
Set a flag specifying whether to hide the pdf viewer application's tool bars when the document is active. The default value is False.
Public methodsetViewerHideWindowUI
Set a flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed. The default value is False.
Public methodsetViewerPageLayout
Set the page layout to be used when the document is opened in a PDF viewer. The default value is PageLayout.OneColumn.
Public methodsetViewerPageMode
Set the document page mode when the pdf document is opened in a PDF viewer. The default value is PageMode.UseNone.
Top
Examples
Merge PDF documents in .NET with SelectPdf online REST API:
using System;
using SelectPdf.Api;

namespace SelectPdf.Api.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string testUrl = "https://selectpdf.com/demo/files/selectpdf.pdf";
            string testPdf = "Input.pdf";
            string localFile = "Result.pdf";
            string apiKey = "Your API key here";

            Console.WriteLine("This is SelectPdf-{0}.", ApiClient.CLIENT_VERSION);

            try
            {
                PdfMergeClient client = new PdfMergeClient(apiKey);

                // set parameters - see full list at https://selectpdf.com/pdf-merge-api/
                client
                    // specify the pdf files that will be merged (order will be preserved in the final pdf)

                    .addFile(testPdf) // add PDF from local file
                    .addUrlFile(testUrl) // add PDF From public url
                    // .addFile(testPdf, "pdf_password") // add PDF (that requires a password) from local file
                    // .addUrlFile(testUrl, "pdf_password") // add PDF (that requires a password) from public url
                ;

                Console.WriteLine("Starting pdf merge ...");

                // merge pdfs to local file
                client.saveToFile(localFile);

                // merge pdfs to memory
                // byte[] pdf = client.save();

                Console.WriteLine("Finished! Number of pages: {0}.", client.getNumberOfPages());

                // get API usage
                UsageClient usageClient = new UsageClient(apiKey);
                UsageInformation usage = usageClient.getUsage(false);
                Console.WriteLine("Conversions remained this month: {0}.", usage.Available);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }
    }
}
See Also