แปลง HTML เป็น PSD ผ่าน Java

ส่งออกไฟล์ HTML ไปยัง PSD ภายในแอปพลิเคชัน Java J2SE, J2EE, J2ME โดยไม่ต้องใช้ Adobe® Acrobat Reader

 

คุณสามารถแปลงไฟล์ html เป็นอิมเมจ PSD ใน Java ได้ในสองขั้นตอนง่ายๆ ประการแรก โดยใช้ Aspose.PDF for Java คุณสามารถส่งออก HTML เป็น JPEG ได้ หลังจากนั้น ด้วยการใช้ Aspose.Imaging for Java Image Processing API คุณสามารถแสดง JPEG เป็น PSD API ทั้งสองอยู่ภายใต้แพ็คเกจ Aspose.Total for Java

ส่งออก HTML เป็น PSD ผ่าน Java

  1. เปิดไฟล์ HTML โดยใช้คลาส Document
  2. เริ่มต้นวัตถุคลาส และแสดง HTML เป็น JPEG โดยใช้ [กระบวนการ]( https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/JpegDevice#process-com aspose.pdf.Page-java.io.OutputStream-) วิธี
  3. โหลดไฟล์ JPEG โดยใช้คลาส Image
  4. บันทึกเอกสารในรูปแบบ PSD โดยใช้ บันทึก กระบวนการ

ข้อกำหนดการแปลง

คุณสามารถใช้ Aspose.Total สำหรับ Java ได้โดยตรงจากโปรเจ็กต์ที่ใช้ Maven และรวมไลบรารี่ไว้ใน pom.xml ของคุณ

หรือคุณสามารถรับไฟล์ ZIP จาก ดาวน์โหลด

// 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());

แปลง HTML เป็น PSD ในไฟล์เดียวผ่าน Java

API ยังอนุญาตให้คุณส่งออกไฟล์ HTML ไปยัง PSD เป็นไฟล์เดียว ในการแปลงหน้าทั้งหมด ก่อนอื่น คุณสามารถแสดงเอกสาร HTML ของคุณเป็นไฟล์ TIFF หนึ่งไฟล์ และหลังจากนั้น คุณสามารถส่งออกไฟล์ TIFF ไปยัง PSD ได้ คุณสามารถเปิดไฟล์อินพุตได้โดยใช้คลาส Document และสร้างอ็อบเจ็กต์อุปกรณ์ Resolution, TiffSettings และ TIFF คุณสามารถรับภาพ TIFF เดียวได้โดยใช้ [กระบวนการ]( https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffDevice#process-com.aspose.pdf.IDocument-int-int- วิธี java.io.OutputStream-) ของคลาส TiffDevice สุดท้าย คุณสามารถโหลดไฟล์ TIFF โดยใช้คลาส Image และบันทึกเป็นรูปแบบ PSD โดยใช้ save 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());

แปลง HTML เป็น PSD ด้วยลายน้ำผ่าน Java

เมื่อใช้ API คุณยังสามารถส่งออกไฟล์ HTML ไปยัง PSD พร้อมลายน้ำในเอกสาร PSD ของคุณได้ ในการเพิ่มลายน้ำให้คุณสามารถแปลง HTML เป็น JPEG และเพิ่มลายน้ำได้ก่อน ในการเพิ่มลายน้ำ ให้โหลดไฟล์รูปภาพโดยใช้คลาส Image สร้างออบเจกต์ของ กราฟิก ://apireference.aspose.com/imaging/java/com.aspose.imaging/Graphics) และเริ่มต้นด้วยวัตถุ Image สร้าง Matrix ใหม่ com.aspose.imaging/Matrix) และตั้งค่าการแปลและการแปลงเป็นมุมที่ต้องการและเพิ่มลายน้ำโดยใช้ Graphics.drawString วิธี หลังจากเพิ่มลายน้ำลงในรูปภาพของคุณแล้ว คุณสามารถบันทึก JPEG เป็นรูปแบบ PSD ได้

// 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());

แปลงและหมุน HTML เป็นไฟล์ PSD ผ่าน Java

เมื่อใช้ API คุณยังสามารถหมุนอิมเมจ PSD ที่ส่งออกได้ตามความต้องการของคุณ วิธี Image.rotateFlip สามารถใช้หมุนภาพได้ 90/180/270 องศา แล้วพลิกภาพในแนวนอนหรือแนวตั้ง ไลบรารีมีวิธีการง่าย ๆ ในการดำเนินการที่ซับซ้อนในขณะที่ห่อหุ้มรายละเอียดที่น่าเกลียดทั้งหมดไว้ คุณสามารถระบุประเภทของการหมุนและพลิกเพื่อใช้กับรูปภาพได้ ในการหมุนและพลิกภาพ คุณสามารถโหลดภาพ JPEG ที่แปลงแล้วโดยใช้คลาส Image และเรียก Image วิธีrotatorFlipขณะระบุ 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());

สำรวจ HTML ตัวเลือกการแปลงด้วย Java

แปลง HTML S TO APNG (กราฟิกเครือข่ายแบบพกพาเคลื่อนไหว)
แปลง HTML S TO DICOM (การถ่ายภาพดิจิทัลและการสื่อสารทางการแพทย์)
แปลง HTML S TO DXF (รูปแบบการแลกเปลี่ยนการวาดของ Autodesk)
แปลง HTML S TO EMZ (Windows บีบอัด Enhanced Metafile)
แปลง HTML S TO JPEG2000 (รูปแบบภาพ J2K)
แปลง HTML S TO JPEG2000 (รูปแบบภาพ J2K)
แปลง HTML S TO SVGZ (กราฟิกแบบเวกเตอร์ที่ปรับขนาดได้ที่ถูกบีบอัด)
แปลง HTML S TO TGA (อะแดปเตอร์กราฟิก Truevision)
แปลง HTML S TO WMF (เมตาไฟล์ของวินโดวส์)
แปลง HTML S TO WMZ (Windows Metafile ที่ถูกบีบอัด)