Multiple FloatingBox

Hi,

I’m trying to create a message like flow in my PDF, so a customer has a conversation in a box on the left side of the page and our replies on the right of the page.

The PDF is created at 0bytes and stays locked in another program (w3wp.exe). Why can’t I create a nice PDF with lots of FloatingBoxes?


foreach (TopicMessage issueMessage in getIssue.Issue.IssueMessages)
{

//start on the left of the page and build up messages
if (issueMessage.Origin == Customer)
{
//this message is from them…
//draw a box on the left with the message
pageSection.Paragraphs.Add(CreateFloatingBox(issueMessage.PersonNickName, “”, issueMessage.MessageText, BoxHorizontalAlignmentType.Left));
}
else
{
//this is a message from us to them
//draw a box on the right
pageSection.Paragraphs.Add(CreateFloatingBox(issueMessage.PersonNickName, “”, issueMessage.MessageText, BoxHorizontalAlignmentType.Right));
}
}

//debugging
pdf1.Save(@“c:\temp” + Guid.NewGuid().ToString() + “.pdf”);
}
return null;
}

private static FloatingBox CreateFloatingBox(string socialNick, string imageUrl, string message,BoxHorizontalAlignmentType position)
{
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(150, 25);

box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
box1.BoxVerticalPositioning = BoxVerticalPositioningType.Paragraph;
box1.BoxVerticalAlignment = BoxVerticalAlignmentType.None;
box1.BoxHorizontalAlignment = position;

box1.Paragraphs.Add(new Text(socialNick));
box1.Paragraphs.Add(new Text(message));

return box1;
}

Hi there,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for NET 8.9.1, We have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-36443 for further investigation and resolution. We will keep you updated about the issue resolution progress via this forum thread.

Please feel free to contact us for any further assistance.

Best Regards,

Hi there,


Thanks for your patience. It is recommend to use tables for the scenario, please check following sample code snippet. Hopefully it will help you accomplish the task.

private static void
MessageFlow()<o:p></o:p>

{

string outFile = myDir+"MessageFlow.pdf";

//Create pdf document

Document doc = new Document();

//Add a section into the pdf document

Page page = doc.Pages.Add();

//Instantiate a table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

tab1.ColumnWidths = "200 200";

Aspose.Pdf.Row row = tab1.Rows.Add();

//this message is from them...

//draw a box on the left with the message

row.Cells.Add(CreateCell("Customer", "", "How does Aspose.Pdf for Java works?"));

//this is a message from us to them

//draw a box on the right

row.Cells.Add(CreateCell("CSR", "", "Aspose.Pdf for Java is a PDF document creation component that enables your Java applications to read, write and manipulate PDF documents without using Adobe Acrobat."));

row = tab1.Rows.Add();

//this message is from them...

//draw a box on the left with the message

row.Cells.Add(CreateCell("Customer", "", "Does Aspose.Pdf for Java suppport table?"));

//this is a message from us to them

//draw a box on the right

row.Cells.Add(CreateCell("CSR", "", "Aspose.Pdf for Java allows you to add tables to PDF documents, you can specify the table border style, margin and padding information, column widths and spanning options, row splitting attributes of tables can also be controlled."));

page.Paragraphs.Add(tab1);

//Save the document

doc.Save(outFile);

}

private static Aspose.Pdf.Cell CreateCell(string socialNick, string imageUrl, string message)

{

Aspose.Pdf.Cell cell = new Aspose.Pdf.Cell();

cell.VerticalAlignment = VerticalAlignment.Top;

cell.Paragraphs.Add(new TextFragment(socialNick));

cell.Paragraphs.Add(new TextFragment(message));

return cell;

}

Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as PDFNEWNET-36443) have been fixed in Aspose.Pdf for .NET 9.1.0.

For further details, you may check this blog post.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.