Puoi convertire il file tex in un’immagine DXF in Java in due semplici passaggi. Innanzitutto, utilizzando Aspose.PDF for Java , puoi esportare TEX in JPEG. Successivamente, utilizzando l’API di elaborazione delle immagini Aspose.Imaging for Java , è possibile eseguire il rendering di JPEG in DXF. Entrambe le API rientrano nel pacchetto Aspose.Total for Java .
Esporta TEX in DXF tramite Java
Requisiti di conversione
Puoi facilmente utilizzare Aspose.Total per Java direttamente da un progetto basato su Maven e includi le librerie nel tuo pom.xml.
In alternativa, puoi ottenere un file ZIP da downloads .
// 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()); |
Converti TEX in DXF in un singolo file tramite Java
L’API consente inoltre di esportare file TEX in DXF in un unico file. Per convertire tutte le pagine, puoi prima eseguire il rendering del tuo documento TEX in un file TIFF e, successivamente, puoi esportare il file TIFF in DXF. È possibile aprire il file di input utilizzando la classe Document e creare oggetti dispositivo Resolution, TiffSettings e TIFF. Puoi ottenere una singola immagine TIFF utilizzando process metodo della classe TiffDevice . Infine, puoi caricare il file TIFF usando la classe Image e salvarlo in formato DXF usando save .
// 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()); |
Converti TEX in DXF con Watermark tramite Java
Utilizzando l’API, puoi anche esportare file TEX in DXF con filigrana nel documento DXF. Per aggiungere una filigrana, puoi prima convertire TEX in JPEG e aggiungere una filigrana. Per aggiungere una filigrana, caricare un file immagine utilizzando la classe Image , creare un oggetto di Graphics e inizializzarlo con l’oggetto Image, creare una nuova Matrix e imposta la traduzione e la trasformazione all’angolo desiderato e aggiungi la filigrana usando Graphics.drawString . Dopo aver aggiunto la filigrana all’immagine, puoi salvare il JPEG come formato DXF.
// 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()); |
Converti e ruota TEX in file DXF tramite Java
Utilizzando l’API, puoi anche ruotare l’immagine DXF di output secondo le tue esigenze. Il metodo Image.rotateFlip può essere utilizzato per ruotare l’immagine di 90/180/270 gradi e capovolgere l’immagine orizzontalmente o verticalmente. La libreria fornisce metodi semplici per eseguire operazioni complesse mentre incapsula tutti i dettagli brutti. È possibile specificare il tipo di rotazione e capovolgimento da applicare all’immagine. Per ruotare e capovolgere l’immagine, è possibile caricare l’immagine JPEG convertita utilizzando la classe Image e chiamare l’immagine. rotateFlip mentre si specifica l’appropriato 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()); |