Quantcast
Channel: Aspose.Pdf for Java
Viewing all articles
Browse latest Browse all 47

Aspose.Pdf for Java 9.7.0

$
0
0
We are pleased to share a new version of Aspose.Pdf for Java with following improvements:

New Features:
PDFNEWJAVA-34192 Support PDF to DOCX conversion
PDFNEWJAVA-34252 Convert PDF to Single Web Archive (MHT file)

Enhancements:
PDFNEWJAVA-34570 Memory is not released after process completion/exits.
PDFNEWJAVA-34357 Memory leak issue
Fixed Bugs:
PDFNEWJAVA-34275 NullPointerException - When converting PDF files to JPG
PDFNEWJAVA-34294 TIFF to PDF - Resultant PDF is blank
PDFNEWJAVA-34529 TIFF to PDF - Exception during image conversion
PDFNEWJAVA-34125 Only first frame of TIFF is converted to PDF
PDFNEWJAVA-34474 Tiff to PDF throws unsupported file format exception
PDFNEWJAVA-34477 TIFF to PDF - Exception during conversion
PDFNEWJAVA-33624 Add a watermark to the same PDF
PDFNEWJAVA-34259 Saving back to the same document throws InvalidPdfFileFormatException exception
PDFNEWJAVA-34482 Multipage TIFF to PDF throws exception
PDFNEWJAVA-34515 Pdf to Image conversion problems for different values of DPI
PDFNEWJAVA-34404 Pdf to text: space between text increased
PDFNEWJAVA-34444 PDF to PDFA: PDFA compliance fails
PDFNEWJAVA-34271 XPS to PDF - Exception during conversion
PDFNEWJAVA-33989 Exception while extracting text from PDF file
PDFNEWJAVA-34423 PDF to Image: loses PolygonAnnotation
PDFNEWJAVA-34532 PDF to HTML - Font missing exception
PDFNEWJAVA-34523 NullPointerException when attempting to get all text from PDF


Public API and Backwards Incompatible Changes

Some untyped public API members has become typed

Changes in com.aspose.pdf.facadesFormattedText class:
public ArrayList getText() -> public List<String> getText()

Changes in com.aspose.pdf.facadesPdfExtractor class:
public Iterable getAttachmentInfo() -> public List<FileSpecification> getAttachmentInfo()

Changes in com.aspose.pdf.facadesPdfFileMend class:
public boolean addText(FormattedText text, int[] pageNums, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY) -> public boolean addText(FormattedText text, Integer[] pageNums, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)

Changes in com.aspose.pdf.generator.legacyxmlmodel.Cell class:
public float FitWidth= 100; -> public float getFitWidth() and public void setFitWidth(float value)

Changes in com.aspose.pdf.generator.legacyxmlmodel.Graph class:
public float GraphWidth -> public float getGraphWidth() and public void setGraphWidth(float value)
public float GraphHeight -> public float getGraphHeight() and public void setGraphHeight(float value)

Changes in com.aspose.pdf.generator.legacyxmlmodel.Heading class:
added:
public /*new*/ boolean IsAutoHyphenated
public /*new*/ Object completeClone_Heading_New()

Changes in com.aspose.pdf.generator.legacyxmlmodel.Heading class:
added:
public String FinalXmStorageFile

Changes in com.aspose.pdf.generator.legacyxmlmodel.Row class:
divided: public float FixedRowHeight -> public float getFixedRowHeight() and public void setFixedRowHeight(float value)

Changes in com.aspose.pdf.generator.legacyxmlmodel.Section class:
moved:
public int ColumnCount
public String ColumnWidths
public String ColumnSpacing

Changes in com.aspose.pdf.Document class:
added: public void afterImport()

Changes in com.aspose.pdf.AppearanceDictionary class:
public XForm get_Item(Object key) -> public XForm get_Item(String key)
public void set_Item(Object key, XForm value) -> public void set_Item(String key, XForm value)
added:
public java.util.List<String> getKeys_()
public java.util.List<XForm> getValues_()
public void addItem(String key, XForm value)
public boolean containsKey(String key)
public boolean removeItemByKey(String key)
public boolean tryGetValue(String key, /*out*/ Object[] value)
deprecated:
public boolean contains(Object key)
public void removeItemInternal(Object key)
public void add(Object key, Object value)
public XForm get(Object key)

Changes in com.aspose.pdf.Artifact class:
public Artifact(ArtifactCollection owner, Resources resources, Matrix matrix, ArrayList _contents, IPdfDictionary _properties ) -> public Artifact(ArtifactCollection owner, ArtifactContext context, List<Operator> _contents, IPdfDictionary _properties)

Changes in com.aspose.pdf.ArtifactCollection class:
public IList findByValue(String name, String expectedValue) -> public List<Artifact> findByValue(String name, String expectedValue)

Changes in com.aspose.pdf.Cells class:
deprecated:
public void remove(Object obj)
added:
public void remove(Cell cell)

Changes in com.aspose.pdf.CheckboxField class:
public java.util.ArrayList getAllowedStates() -> public java.util.List<String> getAllowedStates()

Changes in Color class:
added: extends Brush
public Color deepClone()

Changes in com.aspose.pdf.Image class:
added:
public /*ImageFileType*/int getFileType()
public void setFileType(/*ImageFileType*/int value)

Changes in com.aspose.pdf.InkAnnotation class:
public InkAnnotation(Page page, Rectangle rect, List inkList) -> public InkAnnotation(Page page, Rectangle rect, List<Point[]> inkList)
public IList getInkList() -> public List<Point[]> getInkList()
public void setInkList(IList value) -> public void setInkList(List<Point[]> value)

Changes in com.aspose.pdf.Operator class:
public java.util.ArrayList getParameters() -> public java.util.ArrayList<CommandParameter> getParameters()

Changes in Page class:
public java.util.List getLayers() -> public java.util.List<Layer> getLayers()
public void setLayers(java.util.ArrayList value) -> public void setLayers(java.util.ArrayList<Layer> value)
public IList findReferences(String name) -> public java.util.List<Object> findReferences(String name)
public static IList findReferences(OperatorCollection contents, String name) -> public static java.util.List<Object> findReferences(OperatorCollection contents, String name)
added:
public com.aspose.pdf.Rectangle calculateContentBBox()

Changes in com.aspose.pdf.PageCollection class:
public void delete(int[] pages) -> public void delete(Integer[] pages)
public void add(ICollection pages) -> public void add(Iterable pages)
public void insert(int pageNumber, ICollection pages) -> public void insert(int pageNumber, java.util.List<Page> pages)

Changes in com.aspose.pdf.Table class:
public double getLeft() -> public float getLeft()
public void setLeft(double value) -> public void setLeft(float value)
public double getTop() -> public float getTop()
public void setTop(double value) -> public void setTop(float value)

Added classes:
com.aspose.pdf.Brush
com.aspose.pdf.ImageFileType


RadiusForRoundCorner property was added into com.aspose.pdf.drawing.Rectangle class

Following code snippet shows how to use RadiusForRoundCorner property:

String outFile = "output.pdf";
Document doc = new Document();
Page page = doc.getPages().add();
Graph root = new Graph(100, 100);
com.aspose.pdf.drawing.Rectangle rect = new com.aspose.pdf.drawing.Rectangle(0, 0, 100, 100);
rect.getGraphInfo().setColor (Color.getBlue());
rect.setRadiusForRoundCorner (10);
root.getShapes().add(rect);
page.getParagraphs().add(root);
doc.save(outFile);


Left and Top properties were added into com.aspose.pdf.drawing.Graph class

Following code snippet shows how to use Left, Top properties:

String outFile = "output.pdf";
Document doc = new Document();
Page page = doc.getPages().add();
Graph root = new Graph(100, 100);
root.setLeft (300);
root.setTop (300);
com.aspose.pdf.drawing.Rectangle rect = new com.aspose.pdf.drawing.Rectangle(0, 0, 100, 100);
root.getShapes().add(rect);
page.getParagraphs().add(root);
doc.save(outFile);


calculateContentBBox method was added into com.aspose.pdf.Page object

Following code snippet shows how to trim whitespace from Pdf document:

Document document = new Document("input.pdf");
Page pdfPage = document.getPages().get_Item(1);

Rectangle contentBBox = pdfPage.calculateContentBBox();

document.getPages().get_Item(1).setCropBox (contentBBox);
document.getPages().get_Item(1).setMediaBox (contentBBox);

document.save("output.pdf");


resizeContents method that accepts Document object was added into PdfFileEditor class:

resizeContents(doc, parameters);

Following code snippet shows how to use ResizeContents(doc, parameters) method:

//Create PdfFileEditor Object
PdfFileEditor fileEditor = new PdfFileEditor();

//Open PDF Document
Document doc = new Document("input.pdf");

//Specify Parameter to be used for resizing
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
//left margin = 10% of page width
PdfFileEditor.ContentsResizeValue.percents(30),
//new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
null,
//right margin is 10% of page
PdfFileEditor.ContentsResizeValue.percents(30),
//top margin = 10% of height
PdfFileEditor.ContentsResizeValue.percents(30),
//new contents height is calculated automatically (similar to width)
null,
//bottom margin is 10%
PdfFileEditor.ContentsResizeValue.percents(30)
);

//Resize Page Contents
fileEditor.resizeContents(doc, parameters);

//save document into new location.
doc.save("output.pdf");



PartsEmbeddingModes enumeration was added into com.aspose.pdf.HtmlSaveOptions class.

The PartsEmbeddingModes enumeration includes following values:

EmbedAllIntoHtml
Enforces embed all referenced files(Css,Images,Fonts) into generated HTML markup (i.e. into HTML itself)
This approach generates one HTML file, but total size of output
becames bigger(because Base64 encoding of binaries is in use) and not all browsers (especially legacy)
successfully process binaries embedded into HTML. But it allows get HTML that contains whole result, without any additional files.

EmbedCssOnly
Enforces put apart all referenced files except CSS (Images and Fonts)
I.e. CSS will be embedded into result HTML , and all other referenced files(Images and Fonts)
will be processed as external parts
It generates HTML that is sutable for wide set of browsers

NoEmbedding
Enforces put apart referenced files(Css,Images,Fonts)
This approach generates set of files, but total size of output
becames smaller(because no Base64 encoding of binaries is in use)
Also such approach generates HTML that is sutable for wide set of browsers


PDFNEWJAVA-34252 Convert PDF to Single Web Archive
Following code snippet demonstrates how to embed all resources into html:

Document doc = new Document("input.pdf");

HtmlSaveOptions newOptions = new HtmlSaveOptions();

// this is usage of tested feature
newOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;

// this is just optimozation for IE and can be omitted
newOptions.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
newOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
newOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
//
String outHtmlFile = "output.html";
doc.save(outHtmlFile, newOptions);


GraphInfo property of com.aspose.pdf.drawing.Graph class is marked as obsolete.

GraphInfo properties of Shape objects of Graph.getShapes() collection should be used instead.

Following code snippet shows how to use GraphInfo properties of a Graph's Shape.

Document doc = new Document();
Helper.setLicense();
//Create a section in the Pdf document
Page page = doc.getPages().add();
//Create a graph in the section with Width=100 and Height=400
Graph graph1 = new Graph(50, 150);
//Add the graph object to paragraphs collection of the section
page.getParagraphs().add(graph1);

float[] lineArr = new float[] {110, 10, 10, 10, 10, 110, 110, 110};
Line line = new Line(lineArr);
line.getGraphInfo().setLineWidth (10);
//Set fill color of the circle using GraphInfo property of circle object
line.getGraphInfo().setFillColor (Color.getGreen());
//Enable the circle to be filled with the color specified above line
graph1.getShapes().add(line);

Arc arc = new Arc(110, 60, 50, 90, -90);
graph1.getShapes().add(arc);
arc.getGraphInfo().setColor (Color.getRed());
arc.getGraphInfo().setFillColor (Color.getYellow());
arc.getGraphInfo().setLineWidth (10);
//Enable the circle to be filled with the color specified above line
doc.save("output.pdf");



Viewing all articles
Browse latest Browse all 47

Trending Articles