
Converteer PDF naar SVG of PDF naar TIFF in Java
- [Converteer PDF naar SVG of PDF naar TIFF in Java - API-installatie][6]
- [Java-bibliotheek om PDF naar SVG te converteren][7]
- [PDF programmatisch naar TIFF converteren in Java][8]
Converteer PDF naar SVG of PDF naar TIFF in Java - API-installatie
Conversie en manipulatie van bestandsindelingen wordt vrij eenvoudig door deze Java-bibliotheek in uw Java-toepassing te installeren. U kunt de jar-bestanden [downloaden][9] of u kunt de onderstaande Maven-configuraties volgen. Opslagplaats
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Afhankelijkheid
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>20.12</version>
<classifier>jdk17</classifier>
</dependency>
Java-bibliotheek om PDF naar SVG te converteren
U kunt scripts in de SVG-bestanden comprimeren, indexeren en toevoegen. Daarom vereisen de meeste gevallen de conversie van bestanden naar het SVG-bestandsformaat. U kunt de volgende stappen volgen om deze conversie te bereiken:
- Stel het pad van bron- en uitvoer-PDF-bestanden in.
- Maak een instantie van de klasse [Document][10] en laad het PDF-document.
- Instantiseer een object van de klasse [SvgSaveOptions][11] om toegang te krijgen tot functies voor exporteren naar SVG-indeling.
- Roep deze methode [setCompressOutputToZipArchive][12] aan om op te geven of de uitvoer als één zip-archief wordt gemaakt.
- [Bewaar][13] de uitvoer in SVG-bestanden.
Kopieer en plak de volgende code om PDF programmatisch naar SVG te converteren:
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);
Hoe PDF naar TIFF in Java programmatisch te converteren
In dit gedeelte leert u hoe u de conversie van PDF naar TIFF met Java kunt automatiseren. We zullen dit gedeelte voltooien door de volgende stappen te doorlopen:
- Initialiseer een instantie van de klasse [Document][10] en laad het PDF-document.
- Stel de resolutie van de afbeelding in door een object te maken van [Resolutie][14].
- Maak een object van de klasse [TiffSettings][15] om de instellingen te configureren.
- Roep de methode [setCompression][16] aan om het type compressie in te stellen.
- De methode [setDepth][17] stelt de kleurdiepte in.
- De methode [setShape][18] stelt het type vorm in.
- Maak een instantie van de klasse [TiffDevice][19] om pdf-documenten pagina voor pagina op te slaan in één tiff-afbeelding.
- Roep de methode [proces][20] aan die een PDF-bestand converteert naar een TIFF-afbeelding.
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");
Ontvang een gratis licentie
U kunt een [gratis tijdelijke licentie][21] krijgen om de API zonder evaluatiebeperkingen uit te proberen.
Opsommen
We beëindigen de blogpost hier. We hebben besproken hoe u PDF naar SVG of PDF naar TIFF converteert in Java. Nu hebben we de broncode die PDF naar SVG en PDF naar TIFF-afbeeldingen programmatisch converteert. De hele procedure is lichtgewicht en efficiënt. Er zijn veel andere functies beschikbaar die u kunt verkennen in de [documentatie][22]. Ten slotte schrijft [conholdate.com][23] nieuwe blogposts over andere onderwerpen. Blijf daarom in contact voor regelmatige updates.
Een vraag stellen
Als u vragen heeft, kunt u ons schrijven op het [forum][24].
Zie ook
- [Tekst extraheren uit een PDF-bestand in Java][25]
- [Converteer SVG programmatisch naar PDF in Java][26]
- [Conversie van PDF naar afbeelding in Java - PDF naar PNG, PDF naar JPEG][27] [1]: https://blog.conholdate.com/nl/total/pdf-to-image-conversion-in-java-pdf-to-png-pdf-to-jpeg/ [2]: https://products.aspose.com/pdf/java/ [3]: https://docs.fileformat.com/pdf/ [4]: https://docs.fileformat.com/page-description-language/svg/ [5]: https://docs.fileformat.com/image/tiff/ [6]: #Convert-PDF-to-SVG-or-PDF-to-TIFF-in-Java—API-installation [7]: #Java-library-to-convert-PDF-to-SVG [8]: #How-to-convert-PDF-to-TIFF-in-Java-Programmatically [9]: https://releases.aspose.com/html/java/ [10]: https://reference.aspose.com/pdf/java/com.aspose.pdf/Document [11]: https://reference.aspose.com/html/java/com.aspose.html.dom.svg.saving/SVGSaveOptions [12]: https://reference.aspose.com/pdf/java/com.aspose.pdf/SvgSaveOptions#setCompressOutputToZipArchive-boolean- [13]: https://reference.aspose.com/pdf/java/com.aspose.pdf/Document [14]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/Resolution [15]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffSettings [16]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffSettings#setCompression-int- [17]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffSettings#setDepth-int- [18]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffSettings#setShape-int- [19]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/TiffDevice [20]: https://reference.aspose.com/pdf/java/com.aspose.pdf.devices/DocumentDevice#process-com.aspose.pdf.IDocument-int-int-java.lang.String- [21]: https://purchase.conholdate.com/temporary-license [22]: https://docs.aspose.com/pdf/java/ [23]: https://www.conholdate.com/ [24]: https://forum.conholdate.com/ [25]: https://blog.conholdate.com/nl/total/extract-text-from-a-pdf-file-in-java/ [26]: https://blog.conholdate.com/nl/total/convert-svg-to-pdf-programmatically-in-java/ [27]: https://blog.conholdate.com/nl/total/pdf-to-image-conversion-in-java-pdf-to-png-pdf-to-jpeg/