إعادة عينات الصور المضافة تحويل Excel إلى PDF
Contents
[
Hide
]
أثناء العمل مع ملفات Microsoft Excel الكبيرة مع الكثير من الصور، قد تحتاج إلى ضغط الصور التي تمت إضافتها لتقليل حجم ملف PDF الناتج وتحسين أداء التحويل الكلي. Aspose.Cells تدعم إعادة عينات الصور المضافة لتقليل حجم ملف PDF الناتج وتحسين الأداء بشكل ملحوظ.
يرجى الاطلاع على الكود النموذجي التالي الذي يصف كيفية إجراء المهمة باستخدام واجهة برمجة التطبيقات Aspose.Cells. النموذج يحول ملف Microsoft Excel إلى ملف PDF مع ضغط الصور في الملف.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Initialize a new Workbook | |
// Open an Excel file | |
Workbook workbook = new Workbook(dataDir+ "input.xlsx"); | |
// Instantiate the PdfSaveOptions | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
// Set Image Resample properties | |
pdfSaveOptions.SetImageResample(300, 70); | |
// Save the PDF file | |
workbook.Save(dataDir+ "OutputFile_out_pdf", pdfSaveOptions); |
استخدام ال SetImageResample تقلل حجم ملف ال PDF الناتج لكن قد تؤثر على جودة الصور قليلاً.
إذا كانت جداول البيانات الخاصة بك تحتوي على صيغ، من الأفضل استدعاء Workbook.CalculateFormula() قبل تحويل جدول البيانات إلى تنسيق PDF. وذلك سيضمن إعادة حساب قيم الصيغ الخاصة وتقديم القيم الصحيحة في الملف الناتج PDF.