Hi there,
Currently working on a pdf prototype using ASPOSE.PDF (version 23.11.1). I have followed the instruction on how to create a floating box and adding the text fragments into the box however when the pdf is produced none of the two fragments I have added are in the columns I have specified.
Here is my code that creates the Document object:
private Document ComposeTodaysBusinessSection(DateOnly date)
{
try
{
// Instantiate PDF instance by calling empty constructor
License pdfLicense = new License();
// Specify the license file path
pdfLicense.SetLicense("Aspose.Pdf.lic");
// Create a new Document
Document pdfDocument = new Document
{
PageInfo = new PageInfo
{
Width = PageSize.A4.Width,
Height = PageSize.A4.Height,
Margin = new MarginInfo(0, 0, 0, 0) // Set page margins to zero
}
};
// Add a new page to the PDF document
var page = pdfDocument.Pages.Add();
page.PageInfo.Margin = new MarginInfo(0, 0, 0, 0); // Re-confirm page margins
string meetingMessage = "There are no meetings today";
string futureMeetingMessage = "There are no meetings confirmed in the future.";
// Create TextFragments for the messages
var meetingText = new TextFragment(meetingMessage);
var futureMeetingText = new TextFragment(futureMeetingMessage);
// Create a floating box to hold the columns
FloatingBox box = new FloatingBox
{
ColumnInfo = new ColumnInfo
{
ColumnCount = 2,
ColumnSpacing = "10",
ColumnWidths = "200 200"
},
Left = -55,
Top = 145,
Width = 525,
Height = 580,
Border = new BorderInfo(BorderSide.All),
BackgroundColor = Aspose.Pdf.Color.Tomato,
};
// Create TextFragments for the columns
meetingText.TextState.Font = FontRepository.FindFont("Arial");
meetingText.TextState.FontSize = 14;
meetingText.TextState.ForegroundColor = Color.Black;
futureMeetingText.TextState.Font = FontRepository.FindFont("Arial");
futureMeetingText.TextState.FontSize = 14;
futureMeetingText.TextState.ForegroundColor = Color.Black;
// Add the text fragments to the floating box
box.Paragraphs.Add(meetingText);
box.Paragraphs.Add(futureMeetingText);
// Add the floating box to the page
page.Paragraphs.Add(box);
return pdfDocument;
}
catch (Exception ex)
{
throw ex;
}
}
the result i get:
image.png (17.3 KB)
Any help would be appreciated