PNG
JPG
BMP
TIFF
PDF
C# Cloud APIを使用して複数のPDFファイルをマージする方法
2つのPDFファイルをマージするために、我々は、 Aspose.PDF Cloud .NET SDK このクラウドSDKは、C#、ASP.NET、または他の.NET言語を使用して、さまざまなクラウドプラットフォーム向けのクラウドベースのPDF作成、編集、変換アプリを簡単に構築できるようにします。開く、 NuGet パッケージマネージャー、 Aspose.PDF Cloud を検索し、インストールします。また、パッケージマネージャーコンソールから以下のコマンドを使用することもできます。
コマンド
PM> Install-Package Aspose.Pdf-Cloud
クラウド .NET SDKを使用してPDFをマージする手順
数行のコードで、 Aspose.PDF Cloud .NET SDK APIを使用してPDFをプログラムでマージする基本的な方法。
アプリケーションキーとシークレットで新しい設定オブジェクトを作成します クラウドAPIに接続するオブジェクトを作成します ドキュメントファイルをアップロードします マージを実行します 結果をダウンロードします
C#を使用して2つのPDFファイルをマージ
internal static void MergePdf()
{
const string localImageFileName = @"C:\Samples\sample.pdf";
const string storageFileName1 = "sample1.pdf";
const string storageFileName2 = "sample2.pdf";
const string resultFileName = "merged-doc.pdf";
// Get your AppSid and AppSecret https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
using var file = File.OpenRead(localImageFileName);
pdfApi.UploadFile(storageFileName1, file);
pdfApi.CopyFile(storageFileName1, storageFileName2);
var documentsToBeMerged = new List<string>()
{
storageFileName1, storageFileName2
};
var documents = new Aspose.Pdf.Cloud.Sdk.Model.MergeDocuments(documentsToBeMerged);
pdfApi.PutMergeDocuments(resultFileName, documents);
var response = pdfApi.DownloadFile(resultFileName);
response.CopyTo(File.OpenWrite(resultFileName));
Console.WriteLine();
}