แปลง PS, EPS และ XPS
การแปลง PS, EPS และ XPS ด้วยโซลูชัน API สำหรับ .NET
เมื่อใดก็ตามที่มีความจำเป็นต้องแปลงไฟล์ PostScript PS และ Encapsulated PostScript EPS และเอกสาร XPS ด้วยโปรแกรม .NET API สามารถทำได้อย่างราบรื่นและแปลงไฟล์ได้หลายไฟล์ สำหรับ PS และ EPS นั้น API รองรับตัวดำเนินการ PostScript ระดับ 1-3 และความคิดเห็นส่วนหัวของ EPS ส่วนใหญ่ รวมถึงแปลงเอกสาร PostScript โดยมีความสอดคล้องสูงสุด ยกเว้นในกรณีของฟอนต์บางประเภท และ API จะจัดการกับฟอนต์ เช่น Times New Roman
ยิ่งไปกว่านั้น สำหรับการแปลงไฟล์ XPS นั้น API สามารถเพิ่มหรือลบหน้า จัดการกับแคนวาส เส้นทาง และองค์ประกอบกริฟ (glyph) สร้างรูปทรงกราฟิกแบบเวกเตอร์ และสตริงข้อความ แปลงรายการเค้าร่างของ XPS และอื่นๆ อีกมากมาย
โซลูชัน API สำหรับ .NET ที่นี่ช่วยให้คุณแปลงไฟล์รูปแบบ PDL เช่น PS, EPS และ XPS ด้วยโปรแกรม แต่อาจเป็นประโยชน์สำหรับคุณที่จะได้เห็นและลองใช้แอปพลิเคชันข้ามแพลตฟอร์มที่พัฒนาบน API ดั้งเดิมเหล่านี้
การแปลง PostScript เป็น PDF ผ่าน C# .NET
ในการแปลงไฟล์ PostScript PS และ Encapsulated PostScript EPS เป็น PDF ผ่าน .NET API คุณต้องทำตามขั้นตอนต่อไปนี้:
- โหลดไฟล์ 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 เป็นรูปแบบอื่นทางออนไลน์หรือโดยทางโปรแกรม หากคุณต้องการแปลงไฟล์ออนไลน์ทันที คุณอาจต้องการใช้ Page Description Language format files Converter แอปพลิเคชันข้ามแพลตฟอร์ม
2. ตัวแปลงภาษาใดที่คำอธิบายเพจรองรับ?
ฟังก์ชันการแปลงนี้สนับสนุนไฟล์ที่มีนามสกุล .ps, .eps และ .xps PDL ที่มีชื่อเสียงเช่น PDF และ SVG จะแสดงเป็นโซลูชันแยกต่างหากใน Aspose.products
3. ฟังก์ชั่นฟรีหรือไม่?
ตัวแปลงข้ามแพลตฟอร์ม นั้นฟรี เมื่อสำหรับโซลูชัน API คุณสามารถทดลองใช้งานฟรีแล้วซื้อผลิตภัณฑ์หากจำเป็น
แปลง XPS เป็นรูปภาพ JPG, PNG, BMP ผ่าน C# .NET
.NET API ยังรองรับการแปลง 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?
- รายชื่อลูกค้า
- เรื่องราวความสำเร็จ