HTML JPG PDF XML DOCX
  Product Family
PDF

قص PDF في .NET SDK

API للعمل مع تغيير حجم مستندات PDF باستخدام .NET.

Get Started

كيفية قص مستند PDF عبر Cloud .NET SDK

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

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


    PM> Install-Package Aspose.Pdf-Cloud
     

خطوات قص PDF باستخدام .NET SDK

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

  1. تحميل ملف PDF إلى السحابة.
  2. الحصول على معلومات الصفحة.
  3. استخراج الصفحة كصورة.
  4. إنشاء مستند PDF جديد فارغ.
  5. إدراج الصورة في الـPDF الجديد.
  6. تنزيل ملف PDF النهائي المقصوص.
 

قص PDF باستخدام .NET Cloud SDK


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace ChangeLayout
    {
        public class CropDocumentPage
        {
            private ChangeLayoutHelper _helper;

            public CropDocumentPage(ChangeLayoutHelper helper)
            {
                _helper = helper;
            }

            public async Task MakeCropDocumentPage(string document, string outputDocument, int pageNumber, int llx, int lly, int width, int height)
            {
                await _helper.UploadFile(document);
                await _helper.GetPageInfo(document, pageNumber);
                string imageFile = await _helper.ExtractPdfPage(document, pageNumber, _helper.config.CROP_PAGE_WIDTH, _helper.config.CROP_PAGE_HEIGHT);
                DocumentResponse? newPdf = await _helper.CreatePdfDocument(outputDocument, width, height);
                if (newPdf == null)
                    Console.WriteLine("MakeCropDocumentPage(): Unexpected error - new document is NULL");
                else if (newPdf.Code != 200)
                    Console.WriteLine("MakeCropDocumentPage(): Failed to create new PDF document!");
                else
                {
                    AsposeResponse? response = await _helper.InsertPageAsImage(outputDocument, imageFile, llx, lly);
                    if (response == null)
                        Console.WriteLine("MakeCropDocumentPage(): Unexpected error - insert image return NULL");
                    else if (newPdf.Code != 200)
                        Console.WriteLine("MakeCropDocumentPage(): Failed to insert image to the new PDF document!");
                    else
                    {
                        Console.WriteLine("cropPage(): Page successfully cropped.");
                        await _helper.DownloadFile(outputDocument, "cropped_");
                    }
                }
            }
        }
    }