Rearrange page contents after Text replace, Convert PDF to PDF/A_2a format, amazing PDF to DOC/HTML/Image rendering with Aspose.Pdf for Java 10.2.0

Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Pdf for Java logoA new release of Aspose.Pdf for Java 10.2.0 is published which brings some new features for PDF manipulation. Among these new features, we always strive to make this API robust enough that it can fulfill most of our customers requirements and works without any problem on various configurations. We are pretty much aware that transformation of one file format to other is not an easy task because each format has particular specifications and the rendering mechanism should preserve data, as well formatting when saving resultant file. Keeping all these perspectives in mind, we have made our API capable enough to convert various file formats (including SVG, HTML, Image etc) to PDF format as well as render PDF files to DOC, HTML, Image, XPS etc with great fidelity. These transformation features are one of the salient features being offered by our API and they are endorsed by many clients.

PDF to PDF/A_2a conversion

PDF files conversion to PDF/A compliant documents has been supported by our API for quite sometime and in this new release, we have introduced the support for PDF files to PDF/A_2a compliant format. In order to accomplish this requirement, a new value PDF_A_2A is added in PdfFormat enumeration. For further details, please visit Convert PDF to PDF/A format. Please take a look over following code snippet to convert PDF files to PDF/A_2a compliant format.

//Open document
Document doc = new Document("d:\\input.pdf");
//Convert to PDF/A2_a compliant document
doc.convert("log.log", PdfFormat.PDF_A_2A, com.aspose.pdf.ConvertErrorAction.Delete);
//Save resultant document"d:\\output.pdf");

Auto arrange page contents after text replace

Portable Document Format is one of the complex file formats when it comes to file manipulation as some of the contents placed inside file have relative and others may have obsolete positioning. So during PDF file manipulation, the contents of file might be updated, which may result in extra space besides various elements or the objects may overlap each other due to space limitations. Keeping these issues in mind, we have optimized the text replacement mechanism of our API so that if text inside PDF file is being replaced with small string or if file contents are being replaced with large string(TextFragment), the existing elements over page will automatically adjust them, so that formatting of document is preserved. For more information, we recommend you to visit Text Replacement should automatically re-arrange Page contents.

//Load source PDF file
Document doc = new Document(myDir+"input.pdf");
//Create TextFragment Absorber object with regular expression
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("[Cname,companyname,Textbox,50]");
//Replace each TextFragment
for (TextFragment textFragment : (Iterable)textFragmentAbsorber.getTextFragments())
    // Set font of text fragment being replaced
    textFragment.getTextState().setFont (FontRepository.findFont("Arial"));
    // Set font size
    textFragment.getTextState().setFontSize (12);
    textFragment.getTextState().setForegroundColor (com.aspose.pdf.Color.getNavy());
    // Replace the text with larger string than placeholder
    textFragment.setText ("This is a Lerger String to Testing of this issue");
//Save resultant PDF"29860_out_large_NoHyphenation_1020.pdf");

Miscellaneous fixes

As well as the enhancements and features discussed above, there have been numerous fixes related to recently introduced PDF to TIFF and TIFF to PDF conversion, adding watermark/stamp objects, better support for UniCode characters, working with Annotations, printing PDF documents, SVG to PDF conversion and much more. Please download and try the latest Aspose.Pdf for Java 10.2.0 release.