Java aracılığıyla HTML’yi SVGZ’ye dönüştürün

HTML dosyasını Adobe® Acrobat Reader kullanmadan herhangi bir Java J2SE, J2EE, J2ME uygulamasından SVGZ’ye aktarın

 

Java’da html dosyasını SVGZ görüntüsüne iki basit adımda dönüştürebilirsiniz. İlk olarak, Aspose.PDF for Java kullanarak HTML’yi JPEG’e aktarabilirsiniz. Bundan sonra, Aspose.Imaging for Java Görüntü İşleme API’sini kullanarak JPEG’i SVGZ’ye dönüştürebilirsiniz. Her iki API de Aspose.Total for Java paketi kapsamında gelir.

HTML'yi Java aracılığıyla SVGZ'ye aktarın

  1. Document sınıfını kullanarak HTML dosyasını açın
  2. sınıf nesnesini başlatın ve Process kullanarak HTML’yi JPEG’e dönüştürün. aspose.pdf.Page-java.io.OutputStream-) yöntemi
  3. Image sınıfını kullanarak JPEG dosyasını yükleyin
  4. Belgeyi save kullanarak SVGZ formatına kaydedin-) yöntem

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 HTML'yi SVGZ'ye Dönüştürün

API ayrıca HTML dosyasını SVGZ’ye tek bir dosyaya aktarmanıza olanak tanır. Tüm sayfaları dönüştürmek için önce HTML belgenizi bir TIFF dosyasına dönüştürebilir, ardından TIFF dosyasını SVGZ’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 SVGZ 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ı HTML'yi SVGZ'ye Dönüştürün

API’yi kullanarak, SVGZ belgenizde filigran bulunan HTML dosyasını SVGZ’ye de aktarabilirsiniz. Filigran eklemek için önce HTML’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 SVGZ 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 HTML'yi SVGZ Dosyasına Dönüştür ve Döndür

API’yi kullanarak, çıktı SVGZ 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());

Java ile HTML Dönüşüm Seçeneklerini Keşfedin

HTML s'yi APNG 'ye dönüştürün (Animasyonlu Taşınabilir Ağ Grafikleri)
HTML s'yi DICOM 'ye dönüştürün (Tıpta Dijital Görüntüleme ve İletişim)
HTML s'yi DXF 'ye dönüştürün (Autodesk Çizim Değişim Formatı)
HTML s'yi EMZ 'ye dönüştürün (Windows Sıkıştırılmış Gelişmiş Meta Dosyası)
HTML s'yi JPEG2000 'ye dönüştürün (J2K Görüntü Formatı)
HTML s'yi JPEG2000 'ye dönüştürün (J2K Görüntü Formatı)
HTML s'yi TGA 'ye dönüştürün (Truevision Grafik Adaptörü)
HTML s'yi WMF 'ye dönüştürün (Windows Meta Dosyası)
HTML s'yi WMZ 'ye dönüştürün (Sıkıştırılmış Windows Meta Dosyası)