Reduce PDF Size with Optimized Rendering
Aspose.Words now offers various PDF rendering optimizations to reduce output size when using PdfSaveOptions.OptimizeOutput
settings. This leads to faster transmission and storage for your Apps using our API.
Fit Image to Shape Frame
A new FitImageToShape
public method has been added to the ImageData
class.
The ImageData.FitImageToShape()
method allows developers to automatically resize an image to fit within a specific shape. The aspect ratio of the image data matches the aspect ratio of Shape frame.
This simplifies image manipulation and ensures optimal image display within documents.
This following C# code snippet* demonstrates how to insert a barcode image PNG into a DOCX document and make this image fit to shape via API using ImageData.FitImageToShape()
:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert an image shape and leave its orientation in its default state.
Shape shape = builder.InsertShape(ShapeType.Rectangle, 300, 450);
shape.ImageData.SetImage(ImageDir + "Barcode.png");
shape.ImageData.FitImageToShape();
doc.Save(ArtifactsDir + "Shape.FitImageToShape.docx");
Source*
C# developers can now access and modify the Locked property of a Style, enabling dynamic control over style application.
This provides flexibility for developers to adjust style behavior and achieve desired document formatting.
This following c# snippet* elaborates how to use API to get and set Locked property of a document style:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git.
Document doc = new Document();
Style styleHeading1 = doc.Styles[StyleIdentifier.Heading1];
if (!styleHeading1.Locked)
styleHeading1.Locked = true;
doc.Save(ArtifactsDir + "Styles.LockStyle.docx");
Source*
Recognize Hyperlinks and Make them Clickable
A new public property DetectHyperlinks
has been added to class TxtLoadOptions
.
The App developers can now recognize hyperlinks when loading TXT documents, automatically converting them to clickable links.
This improves user experience by maintaining hyperlink functionality during document conversions.
The following C# code* demonstrates how to recognize hyperlinks when loading TXT documents using API:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git.
const string inputText = "Some links in TXT:\n" +
"https://www.aspose.com/\n" +
"https://docs.aspose.com/words/net/\n";
using (Stream stream = new MemoryStream())
{
byte[] buf = Encoding.ASCII.GetBytes(inputText);
stream.Write(buf, 0, buf.Length);
// Load document with hyperlinks.
Document doc = new Document(stream, new TxtLoadOptions() { DetectHyperlinks = true });
// Print hyperlinks text.
foreach (Field field in doc.Range.Fields)
Console.WriteLine(field.Result);
Assert.AreEqual(doc.Range.Fields[0].Result.Trim(), "https://www.aspose.com/");
Assert.AreEqual(doc.Range.Fields[1].Result.Trim(), "https://docs.aspose.com/words/net/");
}
Source*
For a complete list of features, enhancements, and bug fixes in this release please visit, Aspose.Words for .NET 23.10 Release Notes.