Java’da pdf dosyasını WMF görüntüsüne iki basit adımda dönüştürebilirsiniz. İlk olarak, Aspose.PDF for Java kullanarak PDF’yi JPEG’e aktarabilirsiniz. Bundan sonra, Aspose.Imaging for Java Görüntü İşleme API’sini kullanarak JPEG’i WMF’ye dönüştürebilirsiniz. Her iki API de Aspose.Total for Java paketi kapsamında gelir.
PDF'yi Java aracılığıyla WMF'ye aktarın
Dönüşüm Gereksinimleri
Aspose.Total for Java’yı doğrudan Maven tabanlı bir projeden kolayca kullanabilirsiniz. ve pom.xml’inize kitaplıkları dahil edin.
Alternatif olarak, indirilenler adresinden bir ZIP dosyası alabilirsiniz.
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
Document document = new Document("input.pdf"); | |
// create an object of JpegDevice | |
JpegDevice renderer = new JpegDevice(); | |
// convert first of a particular PDF page to JPEG format | |
renderer.process(document.getPages().get_Item(1), "output.jpeg"); | |
// load JPEG file | |
Image image = Image.Load("output.jpeg"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.save("output.psd", new PsdOptions()); |
Java ile Tek Bir Dosyada PDF'yi WMF'ye Dönüştürün
API ayrıca PDF dosyasını WMF’ye tek bir dosyaya aktarmanıza olanak tanır. Tüm sayfaları dönüştürmek için önce PDF belgenizi bir TIFF dosyasına dönüştürebilir, ardından TIFF dosyasını WMF’ye aktarabilirsiniz. Giriş dosyasını Document sınıfını kullanarak açabilir ve Resolution, TiffSettings ve TIFF aygıt nesneleri oluşturabilirsiniz. process kullanarak tek bir TIFF görüntüsü alabilirsiniz. TiffDevice sınıfının java.io.OutputStream-) yöntemi. Son olarak, Image sınıfını kullanarak TIFF dosyasını yükleyebilir ve save kullanarak WMF formatına kaydedebilirsiniz. apireference.aspose.com/imaging/java/com.aspose.imaging/Image#save-java.lang.String-com.aspose.imaging.ImageOptionsBase-) yöntemi.
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
Document pdfDocument = new Document("input.pdf"); | |
// Create Resolution object | |
Resolution resolution = new Resolution(300); | |
// Create TiffSettings object | |
TiffSettings tiffSettings = new TiffSettings(); | |
tiffSettings.setCompression(CompressionType.None); | |
tiffSettings.setDepth(ColorDepth.Default); | |
tiffSettings.setShape(ShapeType.Landscape); | |
// Create TIFF device | |
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); | |
// Convert a particular page and save the image to stream | |
tiffDevice.process(pdfDocument, 1, 1, "output.tif"); | |
// load TIFF file | |
Image image = Image.Load("output.tif"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save TIFF to PSD file format | |
image.save("output.psd", new PsdOptions()); |
Java ile Filigranlı PDF'yi WMF'ye Dönüştürün
API’yi kullanarak, WMF belgenizde filigran bulunan PDF dosyasını WMF’ye de aktarabilirsiniz. Filigran eklemek için önce PDF’yi JPEG’e dönüştürebilir ve içine bir filigran ekleyebilirsiniz. Filigran eklemek için Image sınıfını kullanarak bir görüntü dosyası yükleyin, Graphics nesnesini oluşturun ://apireference.aspose.com/imaging/java/com.aspose.imaging/Graphics) sınıfını seçin ve Image nesnesiyle başlatın, yeni bir Matrix oluşturun com.aspose.imaging/Matrix) nesnesini seçin ve çeviri ile dönüştürmeyi istediğiniz açıya ayarlayın ve Graphics.drawString kullanarak filigran ekleyin drawString-java.lang.String-com.aspose.imaging.Font-com.aspose.imaging.Brush-float-float-) yöntemi. Resminize filigranı ekledikten sonra JPEG’i WMF formatında kaydedebilirsiniz.
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
Document document = new Document("input.pdf"); | |
// create an object of JpegDevice | |
JpegDevice renderer = new JpegDevice(); | |
// convert first of a particular PDF page to JPEG format | |
renderer.process(document.getPages().get_Item(1), "output.jpeg"); | |
// load JPEG | |
Image image = Image.load("output.jpeg"); | |
// create and initialize an instance of Graphics class | |
Graphics graphics= new Graphics(image); | |
// create an instance of Font | |
Font font = new Font("Times New Roman", 16, FontStyle.Bold); | |
// create an instance of SolidBrush and set its properties | |
SolidBrush brush = new SolidBrush(); | |
brush.setColor(Color.getBlack()); | |
brush.setOpacity(100); | |
Size sz = graphics.getImage().getSize(); | |
// create an object of Matrix class for transformation | |
Matrix matrix = new Matrix(); | |
// first a translation then a rotation | |
matrix.translate(sz.getWidth() / 2, sz.getHeight() / 2); | |
matrix.rotate(-45.0f); | |
// set the Transformation through Matrix | |
graphics.setTransform(matrix); | |
// draw a string using the SolidBrush and Font objects at specific point | |
graphics.drawString("Watermark by Aspose.Imaging for Java", font, brush, 0, 0); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.save("output.psd", new PsdOptions()); |
Java ile PDF'yi WMF Dosyasına Dönüştür ve Döndür
API’yi kullanarak, çıktı WMF görüntüsünü ihtiyaçlarınıza göre de döndürebilirsiniz. Image.rotateFlip yöntemi, görüntüyü 90/180/270 derece döndürmek ve görüntüyü yatay veya dikey olarak çevirmek için kullanılabilir. Kütüphane, tüm çirkin detayları kapsarken karmaşık işlemleri gerçekleştirmek için basit yöntemler sağlar. Görüntüye uygulamak için döndürme ve çevirme türünü belirtebilirsiniz. Görüntüyü döndürmek ve çevirmek için dönüştürülen JPEG görüntüsünü Image sınıfını kullanarak yükleyebilir ve Görüntüyü çağırabilirsiniz. uygun RotateFlipType belirtilirken rotaryFlip yöntemi.
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
Document document = new Document("input.pdf"); | |
// create an object of JpegDevice | |
JpegDevice renderer = new JpegDevice(); | |
// convert first of a particular PDF page to JPEG format | |
renderer.process(document.getPages().get_Item(1), "output.jpeg"); | |
// load JPEG file | |
Image image = Image.Load("output.jpeg"); | |
// roate image | |
image.RotateFlip(RotateFlipType.Rotate270FlipNone); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.save("output.psd", new PsdOptions()); |