आप जावा में सीजीएम फ़ाइल को एपीएनजी छवि में दो सरल चरणों में परिवर्तित कर सकते हैं। सबसे पहले, Aspose.PDF for Java का उपयोग करके, आप JPEG को PDF निर्यात कर सकते हैं। उसके बाद, Aspose.Imaging for Java इमेज प्रोसेसिंग API का उपयोग करके, आप WMF को JPEG रेंडर कर सकते हैं। दोनों एपीआई Aspose.Total for Java पैकेज के तहत आते हैं।
जावा के माध्यम से एपीएनजी को सीजीएम निर्यात करें
- Document वर्ग का उपयोग करके सीजीएम फ़ाइल खोलें
- क्लास ऑब्जेक्ट को इनिशियलाइज़ करें और Process का उपयोग करके JPEG को PDF रेंडर करें। aspose.pdf.Page-java.io.OutputStream-) विधि
- Image क्लास का इस्तेमाल करके JPEG फ़ाइल लोड करें
- [save]( https://reference.aspose.com/imaging/java/com.aspose.imaging/Image#save-java.lang.String-com.aspose.imaging.ImageOptionsBase का उपयोग करके दस्तावेज़ को WMF प्रारूप में सहेजें-) तरीका
रूपांतरण आवश्यकताएँ
आप Maven आधारित प्रोजेक्ट से सीधे Java के लिए Aspose.Total का आसानी से उपयोग कर सकते हैं और अपने pom.xml में पुस्तकालयों को शामिल करें।
वैकल्पिक रूप से, आप डाउनलोड से एक ज़िप फ़ाइल प्राप्त कर सकते हैं।
// 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()); |
जावा के माध्यम से एक ही फाइल में सीजीएम को एपीएनजी में कनवर्ट करें
एपीआई आपको सीजीएम फ़ाइल को एपीएनजी को एक फ़ाइल में निर्यात करने की भी अनुमति देता है। सभी पृष्ठों को बदलने के लिए, आप पहले अपने सीजीएम दस्तावेज़ को एक टीआईएफएफ फ़ाइल में प्रस्तुत कर सकते हैं और उसके बाद, आप टीआईएफएफ फ़ाइल को एपीएनजी में निर्यात कर सकते हैं। आप Document वर्ग का उपयोग करके इनपुट फ़ाइल खोल सकते हैं और रिज़ॉल्यूशन, टिफ़सेटिंग और टीआईएफएफ डिवाइस ऑब्जेक्ट बना सकते हैं। आप TiffDevice वर्ग की विधि। अंत में, आप Image वर्ग का उपयोग करके TIFF फ़ाइल लोड कर सकते हैं और save का उपयोग करके इसे WMF प्रारूप में सहेज सकते हैं। apireference.aspose.com/imaging/java/com.aspose.imaging/Image#save-java.lang.String-com.aspose.imaging.ImageOptionsBase-) विधि।
// 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()); |
जावा के माध्यम से वॉटरमार्क के साथ सीजीएम को एपीएनजी में कनवर्ट करें
एपीआई का उपयोग करके, आप अपने एपीएनजी दस्तावेज़ में वॉटरमार्क के साथ एपीएनजी को सीजीएम फ़ाइल भी निर्यात कर सकते हैं। वॉटरमार्क जोड़ने के लिए आप पहले सीजीएम को जेपीईजी में बदल सकते हैं और उसमें वॉटरमार्क जोड़ सकते हैं। वॉटरमार्क जोड़ने के लिए, Image क्लास का इस्तेमाल करके इमेज फ़ाइल लोड करें, Graphics क्लास और इमेज ऑब्जेक्ट के साथ इसे इनिशियलाइज़ करें, एक नया बनाएं Matrix ऑब्जेक्ट और अनुवाद और रूपांतरण को वांछित कोण पर सेट करें और Graphics.drawString विधि। अपनी छवि में वॉटरमार्क जोड़ने के बाद, आप JPEG को WMF प्रारूप के रूप में सहेज सकते हैं।
// 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()); |
जावा के माध्यम से सीजीएम को एपीएनजी फ़ाइल में कनवर्ट और घुमाएं
एपीआई का उपयोग करके, आप अपनी आवश्यकताओं के अनुसार आउटपुट एपीएनजी छवि को घुमा भी सकते हैं। Image.rotateFlip विधि का उपयोग छवि को 90/180/270-डिग्री तक घुमाने और छवि को क्षैतिज या लंबवत रूप से फ़्लिप करने के लिए किया जा सकता है। पुस्तकालय सभी बदसूरत विवरणों को समाहित करते हुए जटिल संचालन करने के लिए सरल तरीके प्रदान करता है। आप रोटेशन के प्रकार को निर्दिष्ट कर सकते हैं और छवि पर लागू करने के लिए फ्लिप कर सकते हैं। छवि को घुमाने और फ़्लिप करने के लिए, आप Image वर्ग का उपयोग करके परिवर्तित JPEG छवि को लोड कर सकते हैं और छवि को कॉल कर सकते हैं। उपयुक्त RotateFlipType निर्दिष्ट करते हुए रोटेटफ्लिप विधि।
// 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()); |