Hi Team,
I am using aspose slides for cpp. There is a text frame where text is divided into 3 multi columns. I want to be able to extract text according to different columns.
Entire text: Hello, this is the first column. It contains some text. This text is then divided into multi-columns for easy layouting and making the text readable for user. This is the third column. It contains more text
Expected output:
Col1: Hello, this is the first column. It contains some text. This text is then divided into
Col2: multi-columns for easy layouting and making the text readable for
Col3: user. This is the third column. It contains more text
Thanks
@pankajku
To extract text from a multi-column text frame in Aspose.Slides for C++, you can utilize the set_ColumnCount
method to define the number of columns in your text frame. However, extracting the text according to different columns requires a bit of manual handling since the library does not provide a direct method for column-wise extraction.
Here’s a general approach you can follow:
- Load the Presentation: Start by loading your presentation file.
- Access the Text Frame: Navigate to the specific slide and access the text frame that contains the multi-column text.
- Extract Text: Retrieve the text from the text frame and split it based on the number of columns you have defined.
Here’s a sample code snippet to illustrate this process:
#include <aspose.slides.h>
using namespace Aspose::Slides;
int main() {
// Load the presentation
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(u"your_presentation.pptx");
// Access the first slide
System::SharedPtr<ISlide> slide = presentation->GetSlides()->idx_get(0);
// Access the text frame (assuming it's the first shape)
System::SharedPtr<IAutoShape> textBox = System::DynamicCast<IAutoShape>(slide->GetShapes()->idx_get(0));
if (textBox->get_IsTextBox()) {
// Get the text frame
System::SharedPtr<ITextFrame> textFrame = textBox->get_TextFrame();
// Extract text
System::String fullText = textFrame->get_Text();
// Split the text into columns (you may need to adjust this logic based on your layout)
int columnCount = 3; // Assuming 3 columns
std::vector<System::String> columns(columnCount);
// Logic to split fullText into columns based on your specific layout
// This is a placeholder for your splitting logic
columns[0] = u"Col1: " + fullText.Substring(0, 50); // Example split
columns[1] = u"Col2: " + fullText.Substring(50, 50); // Example split
columns[2] = u"Col3: " + fullText.Substring(100); // Example split
// Output the columns
for (int i = 0; i < columnCount; i++) {
std::cout << columns[i].ToUtf8String() << std::endl;
}
}
return 0;
}
In this example, you will need to implement the logic to split the fullText
into the appropriate columns based on your specific layout. The Substring
method is used here as a placeholder to demonstrate how you might extract portions of the text for each column.
This approach allows you to manage the extraction of text from a multi-column layout effectively. If you have specific formatting or layout requirements, you may need to adjust the splitting logic accordingly.
Let me clarify the question in detail.
There is a ppt with text already split into multiple columns. I want to get the exact text present in second column. Currently aspose provides the entire text of text frame. There is no way to find out exactly how much text in present in the second column.
Please help with the same.
@pankajku,
Thanks for providing further details.
We need to evaluate your task/requirements thoroughly. We may devise code snippet for your task or may support relevant APIs. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESCPP-3982
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
PS. We also appreciate if you could share your sample PPT file having text split into multiple column in the frame. Please zip the file prior attaching.
@pankajku,
Thanks for the sample PowerPoint presentation file. I have logged the file with your existing ticket “SLIDESCPP-3982” into our database.
One we have an update on it, we will let you know.