Enhanced PDF Rendering
- Multiple improvements added to optimize PDF output size and processing speed with
PdfSaveOptions.OptimizeOutput. - Easily Render smaller and more efficient PDF documents with Aspose.Words for C++ API.
The updates in this release ensure reduced file sizes and faster performance while rendering PDF documents in C++.
Source*
Streamlined Chart Customization
HasDefaultFormat and CopyFormat methods have been added to the ChartDataPointCollection class.- New method
CopyFormatFrom is added to the ChartSeries class. SetDefaultFill and get_IsDefined methods are added to the ChartFormat class.
Create professional-looking charts with greater control. Customize chart titles, data point formatting, and axis titles.
You can learn how to copy data point format with the help of the following C++ code example:
Document doc = new Document(MyDir + "DataPoint format.docx");
// Get the chart and series to update format.
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
ChartSeries series = shape.Chart.Series[0];
ChartDataPointCollection dataPoints = series.DataPoints;
Assert.IsTrue(dataPoints.HasDefaultFormat(0));
Assert.IsFalse(dataPoints.HasDefaultFormat(1));
// Copy format of the data point with index 1 to the data point with index 2
// so that the data point 2 looks the same as the data point 1.
dataPoints.CopyFormat(0, 1);
Assert.IsTrue(dataPoints.HasDefaultFormat(0));
Assert.IsTrue(dataPoints.HasDefaultFormat(1));
// Copy format of the data point with index 0 to the series defaults so that all data points
// in the series that have the default format look the same as the data point 0.
series.CopyFormatFrom(1);
Assert.IsTrue(dataPoints.HasDefaultFormat(0));
Assert.IsTrue(dataPoints.HasDefaultFormat(1));
doc.Save(ArtifactsDir + "Charts.CopyDataPointFormat.docx");
Source*
Simplified Document Insertion
In this release, a new public method InsertDocumentInline is added to the DocumentBuilder class.
Insert entire documents inline at the current cursor position using the new InsertDocumentInline method.
The following C++ coding sample demonstrates how to effortlessly perform inline content integration from one document to another:
System::SharedPtr<Aspose::Words::DocumentBuilder> srcDoc = System::MakeObject<Aspose::Words::DocumentBuilder>();
srcDoc->Write(u"[src content]");
// Create destination document.
System::SharedPtr<Aspose::Words::DocumentBuilder> dstDoc = System::MakeObject<Aspose::Words::DocumentBuilder>();
dstDoc->Write(u"Before ");
dstDoc->InsertNode(System::MakeObject<Aspose::Words::BookmarkStart>(dstDoc->get_Document(), u"src_place"));
dstDoc->InsertNode(System::MakeObject<Aspose::Words::BookmarkEnd>(dstDoc->get_Document(), u"src_place"));
dstDoc->Write(u" after");
ASSERT_EQ(u"Before after", dstDoc->get_Document()->GetText().TrimEnd(System::MakeObject<System::Array<char16_t>>(0)));
// Insert source document into destination inline.
dstDoc->MoveToBookmark(u"src_place");
dstDoc->InsertDocumentInline(srcDoc->get_Document(), Aspose::Words::ImportFormatMode::UseDestinationStyles, System::MakeObject<Aspose::Words::ImportFormatOptions>());
ASSERT_EQ(u"Before [src content] after", dstDoc->get_Document()->GetText().TrimEnd(System::MakeObject<System::Array<char16_t>>(0)));
Source*
Maintain Aspect Ratio of Images within Shapes
FitImageToShape is the new public method added to the ImageData class in this release of the C++ API.
Preserve the image aspect ratio within shapes and ensure images fit the shapes without distortion.
Please check the following code example, which showcases the usage of the ImageData.FitImageToShape method:
System::SharedPtr<Aspose::Words::Document> doc = System::MakeObject<Aspose::Words::Document>();
System::SharedPtr<Aspose::Words::DocumentBuilder> builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// Insert an image shape and leave its orientation in its default state.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(Aspose::Words::Drawing::ShapeType::Rectangle, 300, 450);
shape->get_ImageData()->SetImage(get_ImageDir() + u"Barcode.png");
shape->get_ImageData()->FitImageToShape();
doc->Save(get_ArtifactsDir() + u"Shape.FitImageToShape.docx");
Source*
Hyperlink Recognition in TXT Files
This release of the C++ API includes a new public property DetectHyperlinks added to the TxtLoadOptions class.
Detect hyperlinks during TXT document loading with the TxtLoadOptions.DetectHyperlinks property.
To learn how to automatically identify hyperlinks in plain text documents using the C++ API, please check out the following example code:
const System::String inputText = System::String(u"Some links in TXT:\n") + u"https://www.aspose.com/\n" + u"https://docs.aspose.com/words/net/\n";
{
System::SharedPtr<System::IO::Stream> stream = System::MakeObject<System::IO::MemoryStream>();
// Clearing resources under 'using' statement
System::Details::DisposeGuard<1> __dispose_guard_0({ stream});
// ------------------------------------------
try
{
System::ArrayPtr<uint8_t> buf = System::Text::Encoding::get_ASCII()->GetBytes(inputText);
stream->Write(buf, 0, buf->get_Length());
// Load document with hyperlinks.
System::SharedPtr<Aspose::Words::Document> doc = System::MakeObject<Aspose::Words::Document>(stream, [&]{ auto tmp_0 = System::MakeObject<Aspose::Words::Loading::TxtLoadOptions>(); tmp_0->set_DetectHyperlinks(true); return tmp_0; }());
// Print hyperlinks text.
for (auto&& field : System::IterateOver(doc->get_Range()->get_Fields()))
{
System::Console::WriteLine(field->get_Result());
}
ASSERT_EQ(doc->get_Range()->get_Fields()->idx_get(0)->get_Result().Trim(), u"https://www.aspose.com/");
ASSERT_EQ(doc->get_Range()->get_Fields()->idx_get(1)->get_Result().Trim(), u"https://docs.aspose.com/words/net/");
}
catch(...)
{
__dispose_guard_0.SetCurrentException(std::current_exception());
}
}
Source*
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Words for C++ 23.10 Release Notes.