تحويل PS و EPS و XPS
تحويل PS و EPS و XPS باستخدام حل واجهة برمجة التطبيقات لـ .NET.
كلما دعت الحاجة إلى تحويل ملفات PostScript PS و Encapsulated PostScript EPS ومستندات XPS برمجياً، يمكن لواجهة برمجة تطبيقات .NET القيام بذلك بسلاسة وتحويل ملفات متعددة. بالنسبة لـ PS و EPS، تدعم واجهة برمجة التطبيقات مشغلات PostScript من المستويات 1-3، ومعظم تعليقات رأس EPS بالإضافة إلى تحويل مستندات PostScript مع أقصى قدر من المطابقة باستثناء بعض حالات الخطوط، وتتعامل واجهة برمجة التطبيقات مع خطوط مثل Time New Roman.
علاوة على ذلك، بالنسبة لتحويل ملفات XPS، يمكن لواجهة برمجة التطبيقات إضافة صفحات أو إزالتها، والتعامل مع الكانفاس والمسارات وعناصر الرموز (glyphs)، وإنشاء أشكال رسومية متجهة، وسلاسل نصية، وتحويل عناصر مخطط XPS، والمزيد.
يتيح لك حل واجهة برمجة تطبيقات .NET هنا تحويل ملفات تنسيقات PDL مثل PS و EPS و XPS برمجياً، ولكن قد تجد من المفيد رؤية وتجربة تطبيقات متعددة المنصات تم تطويرها على واجهات برمجة التطبيقات الأصلية هذه.
تحويل PostScript إلى PDF عبر C# .NET.
لتحويل ملفات PostScript PS و Encapsulated PostScript EPS إلى PDF عبر واجهة برمجة تطبيقات .NET، عليك اتباع الخطوات التالية:
- قم بتحميل ملف PS أو EPS باستخدام الفئة PsDocument .
- أنشئ كائن PdfSaveOptions واضبط خيارات التحويل التي تحتاجها.
- استدعِ PsDocument.SaveAsPdf() مع مسار ملف الإخراج وكائن الخيارات.
كود C# لتحويل PS EPS إلى PDF
// Convert PS file to PDF document.
// Learn more: https://docs.aspose.com/page/net/convert-ps/
// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(DataDir + "input.ps");
// If you want to convert Postscript file despite of minor errors set this flag
bool suppressErrors = true;
//Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
// Default page size is 595x842 and it is not mandatory to set it in PdfSaveOptions
// But if you need to specify sizeuse following line
//PdfSaveOptions options = new PdfSaveOptions(suppressErrorsnew, Aspose.Page.Drawing.Size(595x842));
// or
//saveOptions.Size = new Aspose.Page.Drawing.Size(595x842);
//If PostScript file contains some graphics written as Type3 font glyphs, but it is not actual glyphs
//the resulting PDF may be incorrect because of default value of options.ConvertFontsToTTF = true
//Try to set this
//options.ConvertFontsToTTF = false;
// Save document as PDF
document.SaveAsPdf(OutputDir + "outputPDF_out.pdf", options);
//Review errors
if (suppressErrors)
{
foreach (Exception ex in options.Exceptions)
{
Console.WriteLine(ex.Message);
}
}تحويل PostScript إلى صور عبر C# .NET.
لأي تطبيق محول PostScript EPS/PS إلى صور، يعمل كود C# التالي بشكل جيد، لذا اتخذ الخطوات التالية:
- قم بتحميل ملف PS أو EPS باستخدام الفئة PsDocument .
- أنشئ كائن
ImageSaveOptions
وعيّن
ImageFormatإلى التنسيق المستهدف. - استدعِ PsDocument.SaveAsImage() مع كائن الخيارات.
كود C# لتحويل PostScript إلى صور
// Convert PS file to PNG image.
// Learn more: https://docs.aspose.com/page/net/convert-ps/
//Outut file
string outputFileName = "output_image.png";
// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(DataDir + "inputForImage.ps");
// If you want to convert Postscript file despite of minor errors set this flag
bool suppressErrors = true;
//Initialize options object with necessary parameters.
ImageSaveOptions options = new ImageSaveOptions();
//Set output image format.
options.ImageFormat = Aspose.Page.Drawing.Imaging.ImageFormat.Png;
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
// Save PS document to an image.
document.SaveAsImage(options, OutputDir, Path.GetFileNameWithoutExtension(outputFileName));
//Review errors
if (suppressErrors)
{
foreach (Exception ex in options.Exceptions)
{
Console.WriteLine(ex.Message);
}
}FAQ
1. هل يمكنني تحويل Postscript باستخدام حل API هذا؟
Aspose.Page لديه وظيفة تسمح لك بتحويل ملفات PS و XPS و EPS إلى تنسيقات أخرى عبر الإنترنت أو برمجيًا. إذا كنت بحاجة إلى تحويل ملفاتك فورًا عبر الإنترنت ، فقد ترغب في استخدام تطبيق متعدد الأنظمة الأساسية محول ملفات تنسيق لغة وصف الصفحة .
2. ما هي اللغات التي يدعمها المحول لوصف الصفحة؟
تدعم وظيفة التحويل هذه الملفات ذات الامتدادات .ps و .eps و. xps. يتم تمثيل PDLs الشهيرة مثل PDF و SVG كحلول منفصلة في Aspose.products
3. هل الوظيفة مجانية؟
تعد المحولات متعددة الأنظمة الأساسية مجانية ، عندما يمكنك الحصول على نسخة تجريبية مجانية من حل API ثم شراء المنتج إذا لزم الأمر.
تحويل XPS إلى صور JPG و PNG و BMP عبر C# .NET.
تدعم واجهة برمجة تطبيقات .NET أيضاً تحويل XPS إلى صور BMP و JPG و PNG و TIFF وما إلى ذلك، وتوفر فئة XpsDocument لعمليات XPS. لتحويل XPS إلى صورة، اتبع الخطوات التالية:
- قم بتحميل ملف XPS باستخدام الفئة XpsDocument .
- أنشئ فئة خيارات الحفظ للتنسيق المستهدف — PngSaveOptions أو JpegSaveOptions أو BmpSaveOptions أو TiffSaveOptions .
- اضبط خيارات العرض مثل
SmoothingModeوResolutionوPageNumbers، ثم استدعِ XpsDocument.SaveAsImage() مع كائن الخيارات.
كود C# لتحويل XPS إلى صور
// Convert XPS file to PNG image.
// Learn more: https://docs.aspose.com/page/net/convert-xps/
//Outut file
string outputFileName = "XPStoPNG_out.png";
// Load XPS document form the XPS file
XpsDocument document = new XpsDocument(DataDir + "input.xps", new XpsLoadOptions());
// Initialize options object with necessary parameters.
PngSaveOptions options = new PngSaveOptions()
{
SmoothingMode = SmoothingMode.HighQuality,
Resolution = 300,
PageNumbers = new int[] { 1, 2, 6 }
};
// Save XPS document to the PNG image files.
document.SaveAsImage(options, OutputDir, outputFileName);Support and Learning Resources
- مصادر التعلم
- توثيق
- مصدر الرمز
- مراجع API
- دعم المنتج
- دعم مجاني
- دعم مدفوع
- مقالات
- Release Notes
- لماذا Aspose.Page لـ .NET؟
- قائمة العملاء
- قصص نجاح