مبدل PDF برای .NET
معرفی PDF Converter برای .NET
PDF Converter برای .NET یک پلاگین قدرتمند است که به توسعه دهندگان اجازه می دهد تا فرمت های مختلف فایل ها را به اسناد PDF تبدیل کنند.این راهنمای ارائه یک مرور کلی از ویژگی های موجود، همراه با نمونه های کد در C# برای شما شروع می شود.
تبدیل فایل های Excel به PDF
To convert Excel files to PDF, you can use the Aspose.Cells
namespace. Here’s a simple example:
using Aspose.Cells;
// Load the Excel file
Workbook workbook = new Workbook("example.xlsx");
// Convert the Excel file to PDF
workbook.Save("output.pdf", SaveFormat.Pdf);
In this example, we load an Excel file using the Workbook
class and then save it as a PDF file using the Save
method.
تبدیل تصاویر به PDF
To convert images to PDF, you can use the System.Drawing
namespace in conjunction with Aspose.Cells
در اینجا یک مثال است:
using System.Drawing;
using Aspose.Cells;
// Create a new workbook
Workbook workbook = new Workbook();
// Add the image to the workbook
Worksheet worksheet = workbook.Worksheets.Add();
worksheet.Pictures.Add(1, 1, "image.png");
// Convert the workbook to PDF
workbook.Save("output.pdf", SaveFormat.Pdf);
در این مثال، ما یک فایل تصویر را بارگذاری و آن را به یک دفترچه کار جدید اضافه می کنیم و پس از آن کتاب به عنوان فایل PDF ذخیره می شود.
تنظیم خروجی PDF
You can customize the PDF output by using various options provided by the PdfSaveOptions
class. For example:
using Aspose.Cells;
// Load the Excel file
Workbook workbook = new Workbook("example.xlsx");
// Create a new PdfSaveOptions object
PdfSaveOptions options = new PdfSaveOptions();
// Set the PDF compression
options.PdfCompression = PdfCompressionCore.Flate;
// Set the compliance level to PDF/A-1b
options.Compliance = PdfCompliance.PdfA1b;
// Convert the Excel file to PDF with custom options
workbook.Save("output.pdf", options);
In this example, we create a new PdfSaveOptions
object and set the compression and compliance. We then pass this object to the Save
method to convert the Excel file to PDF with custom options.