
Konversi PDF ke SVG atau PDF ke TIFF di Jawa
- Konversi PDF ke SVG atau PDF ke TIFF di Java - instalasi API
- Pustaka Java untuk mengonversi PDF ke SVG
- Cara mengonversi PDF ke TIFF di Java Secara Terprogram
Konversikan PDF ke SVG atau PDF ke TIFF di Java - instalasi API
Konversi dan manipulasi format file menjadi sangat mudah dengan menginstal pustaka Java ini di aplikasi Java Anda. Anda dapat mengunduh file jar atau Anda dapat mengikuti konfigurasi Maven yang disebutkan di bawah ini. Gudang
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Ketergantungan
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>20.12</version>
<classifier>jdk17</classifier>
</dependency>
Pustaka Java untuk mengonversi PDF ke SVG
Anda dapat mengompres, mengindeks, dan menambahkan skrip di file SVG. Oleh karena itu, sebagian besar kasus memerlukan konversi file ke format file SVG. Anda dapat mengikuti langkah-langkah berikut untuk mencapai konversi ini:
- Tetapkan jalur file PDF sumber & keluaran.
- Buat instance dari kelas Document dan muat dokumen PDF.
- Instansiasi objek kelas SvgSaveOptions untuk mengakses fitur ekspor ke format SVG.
- Panggil metode setCompressOutputToZipArchive ini untuk Menentukan apakah output akan dibuat sebagai satu arsip zip.
- Simpan output dalam file SVG.
Salin dan tempel kode berikut untuk mengonversi PDF ke SVG secara terprogram:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// set the path of source PDF file String pdfFileName = Paths.get( "./sample.pdf").toString(); // set the path of output SVG file String svgFileName = Paths.get("./static/PDFToSVG_out.svg").toString(); // Create an instance of Document class and load the PDF document Document doc = new Document(pdfFileName); // instantiate an object of SvgSaveOptions class to access the export to SVG format features SvgSaveOptions saveOptions = new SvgSaveOptions(); // call this method to Specify whether output will be created as one zip-archive. saveOptions.setCompressOutputToZipArchive(false); // Save the output in SVG files doc.save(svgFileName, saveOptions);
Cara mengonversi PDF ke TIFF di Java Secara terprogram
Bagian ini akan mempelajari cara mengotomatiskan konversi PDF ke TIFF menggunakan Java. Kami akan menyelesaikan bagian ini dengan mencakup langkah-langkah berikut:
- Inisialisasi instance dari kelas Document dan muat dokumen PDF.
- Atur resolusi gambar dengan membuat objek Resolution.
- Buat objek kelas TiffSettings untuk mengonfigurasi pengaturan.
- Panggil metode setCompression untuk menetapkan jenis kompresi.
- Metode setDepth akan mengatur kedalaman warna.
- Metode setShape akan mengatur jenis bentuk.
- Instansiasi instance kelas TiffDevice untuk menyimpan dokumen pdf halaman demi halaman ke dalam satu gambar tiff.
- Aktifkan metode proses yang mengubah file PDF menjadi gambar TIFF.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// set the path of source PDF file String pdfDocumentFileName = Paths.get( ".sample.pdf").toString(); // Initialize an instance of Document class and load the PDF document. Document pdfDocument = new Document(pdfDocumentFileName); // set the resolution of the image by creating an object of Resolution Resolution resolution = new Resolution(300); // Create an object of TiffSettings class to configure the settings TiffSettings tiffSettings = new TiffSettings(); // call this setCompression method to sets the type of the compression. tiffSettings.setCompression(CompressionType.None); // setDepth method will set the color depth. tiffSettings.setDepth(ColorDepth.Default); // setShape method will set the type of the shape. tiffSettings.setShape(ShapeType.Landscape); // Instantiate an instance of TiffDevice class to save pdf document page by page into the one tiff image. TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); // Invoke process method converts a PDF file to TIFF image tiffDevice.process(pdfDocument, "./AllPagesToTIFF_out.tif");
Dapatkan Lisensi Gratis
Anda mungkin mendapatkan lisensi sementara gratis untuk mencoba API tanpa batasan evaluasi.
Menyimpulkan
Kami mengakhiri posting blog di sini. Kami telah mempelajari cara mengonversi PDF ke SVG atau PDF ke TIFF di Java. Sekarang, kami memiliki kode sumber yang mengonversi gambar PDF ke SVG dan PDF ke TIFF secara terprogram. Seluruh prosedurnya ringan dan efisien. Ada banyak fitur lain yang tersedia yang dapat Anda jelajahi di dokumentasi. Terakhir, conholdate.com sedang menulis posting blog baru tentang topik lain. Oleh karena itu, harap tetap berhubungan untuk pembaruan rutin.
Berikan pertanyaan
Jika ada pertanyaan, jangan ragu untuk menulis kepada kami di forum.