HTML JPG PDF XML DOCX
  Product Family
PDF

إضافة صفحات جديدة إلى PDF عبر .NET SDK

API لإضافة الصفحات إلى مستندات PDF باستخدام .NET.

Get Started

كيفية إلحاق الصفحات بمستندات PDF باستخدام Cloud .NET SDK

لإضافة الصفحات إلى مستندات PDF عبر Cloud .NET SDK ، سنستخدم Aspose.PDF Cloud .NET SDK يتيح لك هذا الـ SDK السحابي بناء تطبيقات لإنشاء وتحرير وتحويل ملفات PDF في C# و ASP.NET أو لغات .NET الأخرى لمنصات السحابة المختلفة بسهولة. افتح NuGet مدير الحزم، وابحث عن Aspose.PDF Cloud وقم بالتثبيت. يمكنك أيضًا استخدام الأمر التالي من وحدة تحكم مدير الحزم.

أمر وحدة تحكم مدير الحزم


    PM> Install-Package Aspose.Pdf-Cloud
     

خطوات إضافة الصفحات باستخدام .NET SDK

يمكن لمطوري Aspose.PDF Cloud تحميل وإلحاق الصفحات بمستندات PDF بسهولة في بضعة أسطر من الشفرة.

  1. أنشئ كائن تكوين جديد باستخدام المفتاح والسر الخاصين بتطبيقك.
  2. أنشئ كائنًا للاتصال بـ API السحابي.
  3. قم بتحميل ملف PDF إلى التخزين السحابي.
  4. ألحِق صفحة جديدة بملف PDF في التخزين السحابي.
  5. تحقق من الاستجابة وسجل النتيجة.
  6. حمل الملف المحدث للاستخدام المحلي.
 

توضح هذه الشفرة النموذجية كيفية إضافة الصفحات إلى مستند PDF


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Pages
    {
        public class PagesAdd
        {
            public static async Task Append(string documentName, string outputName, string localFolder, string remoteFolder)
            {
		// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
		pdfApi = new PdfApi(AppSecret, AppSid);

                using (var file = File.OpenRead(Path.Combine(localFolder, documentName)))
		{ // Upload the local PDF to cloud storage folder name.
                    FilesUploadResult uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, documentName), documentName);
                    Console.WriteLine(uploadResponse.Uploaded[0]);
                }

                // Append new page to the PDF on cloud storage.
                DocumentPagesResponse response = await pdfApi.PutAddNewPageAsync(documentName, folder: remoteFolder);

                // Checks the response and logs the result.
                if (response == null)
                    Console.WriteLine("PagesAdd(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("PagesAdd(): Failed to append page to the document.");
                else
                { // Downloads the updated file for local use.
                    Console.WriteLine("PagesAdd(): page successfully appended to the document '{0}.", documentName);
                    Stream stream = pdfApi.DownloadFile(Path.Combine(remoteFolder, documentName));
                    using var fileStream = File.Create(Path.Combine(localFolder, "append_pages_" + outputName));
                    stream.Position = 0;
                    await stream.CopyToAsync(fileStream);
                    Console.WriteLine("PagesAdd(): File '{0}' successfully downloaded.", "append_pages_" + outputName);
                }
            }
        }
    }