We are pleased to share a new version of Aspose.Pdf for Java with following improvements:
New Features:
PDFNEWJAVA-34006 Extract text based on columns
Enhancement:
PDFNEWJAVA-33607 PKCS7 does not support a stream based Constructor
PDFNEWJAVA-34094 Font Folder issue on Non Windows operating systems
Fixed Bugs:
PDFNEWJAVA-34558 TextFragment Underline formatting is not working
PDFNEWJAVA-34695 Exception when loadding PDF processed wtih Apache PDFBox library
PDFNEWJAVA-34690 Extreme slow initial usage of Aspose.PDF/Aspose.Words in Tomcat 8
PDFNEWJAVA-34491 When replacing text, contents overlap in resultant file
PDFNEWJAVA-34680 Setting margin based on level in TOC
PDFNEWJAVA-33567 Digital signature is not properly being added to PDF file
PDFNEWJAVA-34601 TextBoxField.setValue() throws exception
PDFNEWJAVA-34137 verifySignature() method returning false
PDFNEWJAVA-34197 Formatting issues in TOC
PDFNEWJAVA-34350 Signature.verifySignature method is not recognizing signature
PDFNEWJAVA-34458 Exception when trying to extract/get font information for TextFragment
PDFNEWJAVA-34610 Decrypt/Encrypt results in corrupted document or error
PDFNEWJAVA-34606 PDF to HTML: space between text is lost
PDFNEWJAVA-34384 PDF to DOC: Space between text is increased
PDFNEWJAVA-34091 PDF to DOC - Formatting issues in resultant filer
PDFNEWJAVA-34272 PCL to PDF conversion throws NoClassDefFoundError exception
PDFNEWJAVA-34571 PDF to JPEG: White rectangle instead of image's part
PDFNEWJAVA-34555 HtmlFragments Issue: A string longer than a page throws exception.
PDFNEWJAVA-34431 PDF to XML: Resourced are saved in incorrect directory in Linux
PDFNEWJAVA-34425 PDF to DOC - Exception during conversion
PDFNEWJAVA-34022 PCL to PDF - Exception during conversion
Public API and Backwards Incompatible Changes==============
Provided ContainsTransparency property in case SMasked image or stencil mask
Customers can get the transparency information to choose how it is better to save pictures in JPEG or PNG.
Example:final Document pdfDocument = new Document(inputFile);for (int pageCount = 1; pageCount <= 1; pageCount++){for (XImage image : (Iterable<XImage>) pdfDocument.getPages().get_Item(pageCount).getResources().getImages()){if (image.containsTransparency()){System.out.println("Internal image contains transparency");}}}
==============
Feature to Identify if image in PDF is Colored or Black & White
Please use following code snippet to test it and take in attention the black and white images are represented as grayscaled in many cases:Example:final Document document = new Document("inputFile.pdf");
try /*JAVA: was using*/
{
for (Page page : (Iterable<Page>) document.getPages())
{
ImagePlacementAbsorber abs = new ImagePlacementAbsorber();
page.accept(abs);
for (ImagePlacement ia : (Iterable<ImagePlacement>) abs.getImagePlacements())
{
/*ColorType*/int colorType = ia.getImage().getColorType();
switch (colorType)
{case ColorType.Grayscale:System.out.println("Grayscale Image");break;case ColorType.Rgb:System.out.println("Colored Image");break;}
}
}
}
==============
PDFNEWJAVA-34006 Extract text based on columns
Was implemented the next method:
TextExtractionOptions.setScaleFactor (double value); /* 0 */
From now during extracting text in 'Pure' mode You can specify ScaleFactor option.
This scale factor may be set to adjust grid that used for the internal text formatting mechanism during text extraction. Specifying of ScaleFactor values between 1 and 0.1 (including 0.1) has the same effect as font reducing. However the first is not change input document in contrast of second. And it works more faster and makes code more simple.
Specifying of ScaleFactor values between 0.1 and -0.1 is treated as zero value. It makes algorithm to calculate scale factor needed during extracting text automatically. The calculation is based on average glyph width of most popular font on the page. But we can not warrant that in extracted text no one string of column is reached the start of next column.
If ScaleFactor value is not specified, the default value of 1.0 will be used. It means no scaling will be carried out.
If specified ScaleFactor value is more than 10 or less than -0.1, the default value of 1.0 will be used.
We propose you to try use auto-scaling (ScaleFactor = 0) in mass processing PDF-document text content extraction. Or manually set redundant reducing of grid width ( about ScaleFactor = 0.5). You must not determine whether scaling is necessary for concrete document or not. If You set redundant reducing of grid width for the document (that doesn't need in it) the extracted text content will be remain fully adequate.
By default algorithm takes into account value of font size that have already reduced due to some internal reasons. For example reducing font size from 10 to 7 has the same effect as setting scale factor to 5/8 (= 0.625).
Example:Document pdfDocument = new Document("inputFile.pdf");TextAbsorber textAbsorber = new TextAbsorber();textAbsorber.setExtractionOptions(new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Pure));//Setting scale factor to 0.5 is enough to split columns in the majority of documents//Setting of zero allows to algorithm choose scale factor automaticallytextAbsorber.getExtractionOptions().setScaleFactor((double)0.5);pdfDocument.getPages().accept(textAbsorber);String extractedText = textAbsorber.getText();
==============
Feature to support of generating multi-layered PDF
Example:Document doc = new Document();Page page = doc.Pages.Add();Layer layer = new Layer("oc1", "Red Line");layer.Contents.Add(new Operator.SetRGBColorStroke(1, 0, 0));layer.Contents.Add(new Operator.MoveTo(500, 700));layer.Contents.Add(new Operator.LineTo(400, 700));layer.Contents.Add(new Operator.Stroke());page.Layers = new List<Layer>();page.Layers.Add(layer);layer = new Layer("oc2", "Green Line");layer.Contents.Add(new Operator.SetRGBColorStroke(0, 1, 0));layer.Contents.Add(new Operator.MoveTo(500, 750));layer.Contents.Add(new Operator.LineTo(400, 750));layer.Contents.Add(new Operator.Stroke());page.Layers.Add(layer);layer = new Layer("oc3", "Blue Line");layer.Contents.Add(new Operator.SetRGBColorStroke(0, 0, 1));layer.Contents.Add(new Operator.MoveTo(500, 800));layer.Contents.Add(new Operator.LineTo(400, 800));layer.Contents.Add(new Operator.Stroke());page.Layers.Add(layer);doc.Save("output.pdf");
==============
Feature to support to control footnote line
Example:Document doc = new Document();Helper.SetLicense();Page page = doc.Pages.Add();GraphInfo graph = new GraphInfo();graph.LineWidth = 2;graph.Color = Color.Red;graph.DashArray = new int[] { 3 };graph.DashPhase = 1;page.NoteLineStyle = graph;TextFragment text = new TextFragment("test text 1");text.FootNote = new Note("foot note for test text 1");page.Paragraphs.Add(text);text = new TextFragment("test text 2");text.FootNote = new Note("foot note for test text 2");page.Paragraphs.Add(text);doc.Save(outFile);
================
Feature to disable file compression when adding as embedded resources
Encoding property was added to FileSpecification class.
This property determines which encoding will be used for file compressing.
This property may have value of FileEncoding enumarator.
For now possible values are FileEncoding.None and FileEncoding.Zip.
If Encoding is set to FileEncoding.None then attachment is not compressed.
By default Encoding have FileEncoding.Zip value.
Example:Document pdfDocument = new Document("input.pdf");//setup new file to be added as attachmentFileSpecification fileSpecification = new FileSpecification("test.txt", "Sample text file");//Specify Encoding proparty setting it to FileEncoding.NonefileSpecification.setEncoding (FileEncoding.None);//add attachment to document's attachment collectionpdfDocument.getEmbeddedFiles().add(fileSpecification);//save new outputpdfDocument.save("output.pdf");
================
com.aspose.pdf.facades.Form class:
Deprecated methods:
public OutputStream getDestStream()
public void setDestStream(OutputStream value)
Deprecated constructor:
public Form(InputStream srcStream, OutputStream destStream)
com.aspose.pdf.facades.PdfFileEdito class:
Added internal class:
public static class PageBreak
Added methods:
public void addPageBreak(Document src, Document dest, PageBreak[] pageBreaks)
public void addPageBreak(String src, String dest, PageBreak[] pageBreaks)
com.aspose.pdf.facades.PdfFileStamp class:
Deprecated methods:
public String getInputFile()
public void setInputFile(String value)
public InputStream getInputStream()
public void setInputStream(InputStream value)
public String getOutputFile()
public void setOutputFile(String value)
public OutputStream getOutputStream()
public void setOutputStream(OutputStream value)
com.aspose.pdf.facades.AutoFiller class:
Deprecated methods:
public OutputStream getOutputStream()
public void setOutputStream(OutputStream value)
public InputStream getInputStream()
public void setInputStream(InputStream value)
com.aspose.pdf.facades.FormEditor class:
Deprecated constructors:
public FormEditor(IDocument document, OutputStream destStream)
public FormEditor(IDocument document, String destFileName)
public FormEditor(InputStream srcStream, OutputStream destStream)
com.aspose.pdf.facades.PdfFileMend class:
Deprecated constructors:
public PdfFileMend(IDocument document, String outputFileName)
com.aspose.pdf.facades.PdfFileSecurity class:
Deprecated methods:
public void setInputStream(InputStream value)
public void setOutputStream(OutputStream value)
Deprecated constructors:
public PdfFileSecurity(InputStream inputStream, OutputStream outputStream)
com.aspose.pdf.generator.legacyxmlmodel.PathArea class:
Added method:
public java.util.Map getShapes()
com.aspose.pdf.generator.legacyxmlmodel.ShadingPattern class:
Added method:
public java.awt.Color getColor()
com.aspose.pdf.generator.legacyxmlmodel.ShadingPatternFactory class:
Added method:
public static ShadingPattern getShadingPattern(int level,java.awt.Color color)
com.aspose.pdf.Document class:
Added methods:
public boolean getAllowReusePageContent()
public void setAllowReusePageContent(boolean value)
com.aspose.pdf.Artifact class:
Added methods:
public void setImage(InputStream imageStream)
com.aspose.pdf.ArtifactCollection class:
Added methods:
public java.util.List<Artifact> findByValue(String name, String expectedValue)
com.aspose.pdf.BackgroundArtifact class:
Added methods:
public InputStream getBackgroundImage()
com.aspose.pdf.BaseParagraph class:
Added methods:
public boolean isInLineParagraph()
public void setInLineParagraph(boolean value)
com.aspose.pdf.BaseParagraph class:
Changes in methods:
public java.awt.geom.Point2D.Float getPageSize() -> public java.awt.geom.Dimension2D getPageSize()
public void setPageSize(java.awt.geom.Point2D.Float value) - > public void setPageSize(java.awt.geom.Dimension2D value)
com.aspose.pdf.CgmLoadOptions class:
Changes in methods:
public java.awt.geom.Point2D.Float getPageSize() -> public java.awt.geom.Dimension2D getPageSize()
public CgmLoadOptions(java.awt.geom.Point2D.Float pageSize) -> public CgmLoadOptions(java.awt.geom.Dimension2D pageSize)
com.aspose.pdf.Color class:
Added methods:
public PatternColorSpace getPatternColorSpace()
public void setPatternColorSpace(PatternColorSpace value)
com.aspose.pdf.ComHelper class:
Added methods:
public Document openStream(InputStream input)
public Document openStream(InputStream input, String password)
public Document openStream(InputStream input, boolean isManagedStream)
public Document openStream(InputStream input, String password, boolean isManagedStream)
public Document openStream(InputStream input, LoadOptions options)
com.aspose.pdf.ComHelper class:
Added constructors:
public ContentsAppender(XForm form)
com.aspose.pdf.ComHelper class:
Added methods:
public void setCreationDate(java.util.Date value)
public double getCreationTimeZone()
public void setCreationTimeZone(double value)
public double getModTimeZone()
public void setModTimeZone(double value)
public java.util.Date getModDate()
public void setModDate(java.util.Date value)
com.aspose.pdf.FileParams class:
Added methods:
public java.util.Date getCreationDate()
public void setCreationDate(java.util.Date value)
public java.util.Date getModDate()
public void setModDate(java.util.Date value)
Added constructor:
public FileParams(FileSpecification spec)
com.aspose.pdf.FileParams class:
Added methods:
public /*FileEncoding*/int getEncoding()
public void setEncoding(/*FileEncoding*/int value)
public void setParams(FileParams value)
com.aspose.pdf.FloatingBox class:
Changes:
public /*VerticalAlignment*/int _VerticalAlignment; ->
public /*VerticalAlignment*/int getVerticalAlignment_Rename_Namesake() and public void setVerticalAlignment_Rename_Namesake(/*VerticalAlignment*/int value)
com.aspose.pdf.IIndexBitmapConverte class:
Added methods:
public java.awt.image.BufferedImage get1BppImage(java.awt.image.BufferedImage src);
public java.awt.image.BufferedImage get4BppImage(java.awt.image.BufferedImage src);
public java.awt.image.BufferedImage get8BppImage(java.awt.image.BufferedImage src);
com.aspose.pdf.Image class:
Changes:
public /*ImageFileType*/int getFileType() -> public/* ImageFileType */int getFileType()
public void setFileType(/*ImageFileType*/int value) -> public void setFileType(/* ImageFileType */int value)
Added methods:
public boolean isBlackWhite()
public void setBlackWhite(boolean value)
com.aspose.pdf.Layer class:
Added methods:
public java.util.List<Operator> getContents()
com.aspose.pdf.LevelFormat class:
Changes:
public aspose.pdf.MarginInfo getMargin() -> public com.aspose.pdf.MarginInfo getMargin()
public void setMargin(aspose.pdf.MarginInfo value) -> public void setMargin(com.aspose.pdf.MarginInfo value)
com.aspose.pdf.Page class:
Added methods:
public GraphInfo getNoteLineStyle()
public void setNoteLineStyle(GraphInfo value)
com.aspose.pdf.Page class:
Added fields:
public boolean SupressErrors;
com.aspose.pdf.Page class:
Added constructor:
public PKCS7Detached(InputStream pfx, String password)
com.aspose.pdf.SoundData class:
Added methods:
public InputStream getContents()
com.aspose.pdf.TextExtractionOptions class:
Added methods:
public double getScaleFactor()
public void setScaleFactor(double value)
com.aspose.pdf.TextFragment class:
Added methods:
public Note getEndNote()
public void setEndNote(Note value)
public Note getFootNote()
public void setFootNote(Note value)
com.aspose.pdf.TextFragmentState class:
Added methods:
public float getCharacterSpacing()
com.aspose.pdf.TextStamp class:
Added methods:
public boolean getDraw()
public void setDraw(boolean value)
com.aspose.pdf.TextStamp class:
Added methods:
public float getCharacterSpacing()
com.aspose.pdf.TocInfo class:
Added methods:
public void setLevelIndentation(int value)
public int getLevelIndentation()
com.aspose.pdf.XImage class:
Added methods:
public boolean containsTransparency()
public /*ColorType*/int getColorType()
com.aspose.pdf.License class:
Added throws Exception to the methods setLicense:
public void setLicense(InputStream stream) throws Exception
public void setLicense(String licenseName) throws Exception
Added newclass com.aspose.pdf.Note
Added new class com.aspose.pdf.facades.PdfPrintPageInfo
Added newenum class com.aspose.pdf.FileEncoding