You can convert xslfo file to SVGZ image in Java in two simple steps. Firstly, by using Aspose.PDF for Java , you can export XSLFO to JPEG. After that, by using Aspose.Imaging for Java Image Processing API, you can render JPEG to SVGZ. Both APIs come under the Aspose.Total for Java package.
Convert XSLFO to SVGZ in a Single File via Java
The API also allows you to export XSLFO file to SVGZ to a single file. In order to convert all pages, you can first render your XSLFO document to one TIFF file and after that, you can export the TIFF file to SVGZ. You can open the input file using Document class and create Resolution, TiffSettings, & TIFF device objects. You can get a single TIFF image using process method of TiffDevice class. Finally, you can load TIFF file using Image class and save it to SVGZ format using save method.
Convert XSLFO to SVGZ With Watermark via Java
Using the API, you can also export XSLFO file to SVGZ with watermark in your SVGZ document. In order to add a watermark to you can first convert XSLFO to JPEG and add a watermark in it. In order to add watermark, load an image file using the Image class, create an object of the Graphics class and initialize it with Image object, create a new Matrix object and set translation and transformation to the desired angle and add watermark using Graphics.drawString method. After adding the watermark in your image, you can save the JPEG as SVGZ format.
Convert & Rotate XSLFO to SVGZ File via Java
Using the API, you can also rotate the output SVGZ image as per your needs. The Image.rotateFlip method can be used to rotate the image by 90/180/270-degrees and flip the image horizontally or vertically. The library provides simple methods to perform complex operations while encapsulating all ugly details. You can specify the type of rotation and flip to apply to the image. In order to rotate and flip the image, you can load the converted JPEG image using the Image class and call the Image.rotateFlip method while specifying the appropriate RotateFlipType .
Explore XSLFO Conversion Options with Java
What is XSLFO File Format
XSLFO is a XML-based page description language. It is most often used to generate PDF documents from XML data. XSLFO defines the layout and appearance of pages and page elements. It includes features for defining the size and position of pages and page elements, the font and color of text, and the rules for flowing text from one page to another. XSLFO is part of the XSLT standard, and can be used with any XML document.
Read MoreWhat is SVGZ File Format
Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999.SVG images and their behaviors are defined in XML text files. This means that they can be searched, indexed, scripted, and compressed. As XML files, SVG images can be created and edited with any text editor, but are more often created with drawing software. These are then optimized using a variety of tools before being published on the web.SVG images can be created in a vector drawing program like Adobe Illustrator, Inkscape, or Sketch.Once created, the SVG file can be compressed using gzip to create a smaller file, which is then referred to as an SVGZ file.
Read More