PS, EPS ve XPS’i Dönüştürün

Java için PS, EPS ve XPS Dönüştürücü API Çözümü

 

PostScript PS ve Encapsulated PostScript EPS dosyalarını ve XPS belgelerini programlı olarak dönüştürme ihtiyacı duyulduğunda, Java API bunu sorunsuz bir şekilde yapabilir ve birden fazla dosyayı dönüştürebilir. PS ve EPS için API, Seviye 1-3 PostScript operatörlerini ve EPS başlık yorumlarının çoğunu destekler ve birkaç yazı tipi durumu dışında maksimum uygunlukla PostScript belgelerini dönüştürür; API bu tür yazı tiplerini Time New Roman olarak işler.

Dahası, XPS dosyası dönüşümü için API, sayfa ekleyebilir veya çıkarabilir, tuval (canvas), yol (path) ve glif (glyph) öğeleriyle ilgilenebilir, vektör grafikleri şekilleri ve metin dizeleri oluşturabilir, XPS anahat öğelerini dönüştürebilir ve daha fazlasını yapabilir.

Buradaki Java API çözümü, PS, EPS ve XPS gibi PDL formatlarındaki dosyaları programlı olarak dönüştürmenize olanak tanır, ancak bu yerel API'ler üzerinde geliştirilen platformlar arası araçları görmek ve denemek faydalı olabilir.

Java Üzerinden PostScript'ten PDF'e Dönüştürme.

PostScript PS ve Encapsulated PostScript EPS dosyalarını Java API aracılığıyla PDF'e dönüştürmek için sonraki adımları uygulamanız gerekir:

  1. PS veya EPS dosyasını PsDocument sınıfını kullanarak yükleyin.
  2. Bir PdfSaveOptions nesnesi oluşturun ve ihtiyacınız olan dönüştürme seçeneklerini ayarlayın.
  3. PsDocument.saveAsPdf() yöntemini çıktı dosyası yolu ve seçenekler nesnesiyle çağırın.
PS EPS'yi PDF'e Dönüştürmek İçin Java Kodu
// Convert PS file to PDF document.
// Learn more: https://docs.aspose.com/page/java/convert-ps/

// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(getDataDir() + "input.ps");

// If you want to convert Postscript file despite of minor errors set this flag
boolean 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.setAdditionalFontsFolders(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, java.awt.Dimension(595x842));
// or
//saveOptions.setSize(new java.awt.Dimension(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.setConvertFontsToTTF(false);

// Save document as PDF
document.saveAsPdf(getOutputDir() + "outputPDF_out.pdf", options);

//Review errors
if (suppressErrors) {
    for (Exception ex : options.getExceptions()) {
        System.out.println(ex.getMessage());
    }
}
 

Java Üzerinden PostScript'ten Görüntülere Dönüştürme.

Herhangi bir EPS/PS PostScript'ten görüntüye dönüştürücü uygulaması için aşağıdaki Java kodu iyi çalışır, bu nedenle sonraki adımları izleyin:

  1. PS veya EPS dosyasını PsDocument sınıfını kullanarak yükleyin.
  2. Hedef görüntü biçimi için bir ImageSaveOptions nesnesi oluşturun.
  3. PsDocument.saveAsImage() yöntemini seçenekler nesnesi, çıktı klasörü ve dosya adıyla çağırın.
PostScript'ten Görüntülere Dönüştürme İçin Java Kodu
// Convert PS file to PNG image.
// Learn more: https://docs.aspose.com/page/java/convert-ps/

//Outut file 
String outputFileName = "output_image.png";

// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(getDataDir() + "inputForImage.ps");

// If you want to convert Postscript file despite of minor errors set this flag
boolean suppressErrors = true;

//Initialize options object with necessary parameters.
ImageSaveOptions options = new ImageSaveOptions();

//Set output image format.
options.setImageFormat(ImageFormat.PNG);

// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.setAdditionalFontsFolders(new String[] { "{FONT_FOLDER}" });

// Save PS document to an image.
document.saveAsImage(options, getOutputDir(), getFileNameWithoutExtension(outputFileName));

//Review errors
if (suppressErrors) {
    for (Exception ex : options.getExceptions()) {
        System.out.println(ex.getMessage());
    }
}
 

Java Üzerinden XPS'i JPG, PNG, BMP Görüntülerine Dönüştürün.

Java API, sayfa düzenini temsil etmek için kullanılan XPS formatını işler. Herhangi bir senaryoda, XPS'i programlı olarak BMP, JPG, PNG ve TIFF görüntülerine dönüştürme ihtiyacı duyulduğunda, aşağıdaki kod Java uygulamasına kolayca entegre edilebilir.

  1. XPS belgesini XpsDocument sınıfını kullanarak yükleyin.
  2. Hedef biçim için kaydetme seçenekleri sınıfını oluşturun — PngSaveOptions , JpegSaveOptions , BmpSaveOptions veya TiffSaveOptions .
  3. XpsDocument.saveAsImage() yöntemini seçenekler nesnesi, çıktı klasörü ve dosya adıyla çağırın.
XPS'ten Görüntüye Dönüştürme İçin Java Kodu
// Convert XPS file to PNG image.
// Learn more: https://docs.aspose.com/page/java/convert-xps/

//Outut file 
String outputFileName = "XPStoPNG_out.png";

// Load XPS document form the XPS file
XpsDocument document = new XpsDocument(getDataDir() + "input.xps");

// Initialize options object with necessary parameters.
PngSaveOptions options = new PngSaveOptions();
options.setSmoothingMode(SmoothingMode.HighQuality);
options.setResolution(300);
options.setPageNumbers(new int[] { 1, 2, 6 });

// Save XPS document to the PNG image files.
document.saveAsImage(options, getOutputDir(), outputFileName);



FAQ

1. Bu API çözümüyle Postscript’i dönüştürebilir miyim?

Aspose.Page, PS, XPS ve EPS dosyalarını çevrimiçi veya programlı olarak diğer biçimlere dönüştürmenize olanak tanıyan işlevselliğe sahiptir. Dosyalarınızı anında çevrimiçi dönüştürmeniz gerekiyorsa, platformlar arası Sayfa Açıklama Dil biçimi dosyaları Dönüştürücü uygulamasını kullanmak isteyebilirsiniz.

2. Dönüştürücü hangi Sayfa açıklama dillerini destekler?

Bu dönüştürme işlevi, .ps, .eps ve .xps uzantılı dosyaları destekler. PDF ve SVG gibi ünlü PDL’ler Aspose.products’ta ayrı çözümler olarak sunulmaktadır.

3. İşlev ücretsiz mi?

Platformlar arası dönüştürücüler ücretsizdir, API çözümü için ücretsiz Deneme sürümü alabilir ve ardından gerekirse ürünü satın alabilirsiniz.

 

Java Üzerinden XPS'i PDF'e Dönüştürün.

XPS'i programlı olarak PDF belgelerine dönüştürme işlemi basittir ve giriş ve çıktı dosyaları arasında yüksek doğrulukta sonuçlar verir.

  1. XPS dosyasını XpsDocument sınıfını kullanarak yükleyin.
  2. Bir PdfSaveOptions nesnesi oluşturun.
  3. XpsDocument.saveAsPdf() yöntemini çıktı dosyası yolu ve seçenekler nesnesiyle çağırın.
XPS'ten PDF'e Dönüştürme İçin Java Kodu
// Convert XPS file to PDF document.
// Learn more: https://docs.aspose.com/page/java/convert-xps/

// Load XPS document form the XPS file
XpsDocument document = new XpsDocument(getDataDir() + "input.xps");

// Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions();
options.setJpegQualityLevel(100);
options.setImageCompression(PdfImageCompression.Jpeg);
options.setTextCompression(PdfTextCompression.Flate);
options.setPageNumbers(new int[] { 1, 2, 6 });

// Save document as PDF
document.saveAsPdf(getOutputDir() + "XPStoPDF_out.pdf", options);
 
  

Support and Learning Resources