Free Support Forum - aspose.com

Pleasement issue is with Image with Paragraph

Here is my programs:


AnswerText = new Text();

AnswerSegment = new Segment(AnswerText);
AnswerSegment.Content = "Demo 123";
AnswerText.Segments.Add(CheckBoxSegment); //Checkbox Image
AnswerText.Segments.Add(AnswerSegment); //Text

AnswerText.Segments.Add(CommentRequiredSegment); //Pencil Image

ItemRow.Cells[2].Paragraphs.Add(AnswerText);


The above code will repeat based on loop. Text would be display like checkbox image then text then pencil image.

The issue is with the pencil image is not displaying at the end of the line... Please check attached image for reference.

Thanks



Hi jmhemadri,

Thank you for the sample code. I tried using your code to test your issue but due to missing variable values, I was unable to replicate the scenario at my end. Please create a sample application to show the issue. This will help us figure out the issue and reply back to you soon.

Thanks & Regards,

Hello

Here is the example of code.

Aspose.Pdf.Image PencilImage = new Aspose.Pdf.Image();

PencilImage.ImageInfo.File = HttpContext.Current.Server.MapPath("~/images/pencil.gif");

Aspose.Pdf.Segment CommentRequiredSegment;

CommentRequiredSegment = new Segment();

CommentRequiredSegment.InlineParagraph = PencilImage;

Pdf pdfConv = new Pdf();

Section sec1 = pdfConv.Sections.Add();

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

sec1.Paragraphs.Add(tab1);

tab1.ColumnWidths="250";

Text AnswerText;

Segment AnswerSegment;

string[] text = { "Line 1", "Line No 2", "This is Line no 3", "This is last line no 4","This is final last line no 4" };

for (int i = 0; i < 5; i++)

{

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

AnswerText = new Text();

AnswerSegment = new Segment(AnswerText);

AnswerSegment.Content = text[i];

AnswerText.Segments.Add(AnswerSegment);

AnswerText.Segments.Add(CommentRequiredSegment);

row1.Cells.Add();

row1.Cells[0].Paragraphs.Add(AnswerText);

}

pdfConv.Save(@"m:\temp\Image_in_Cell" + Guid.NewGuid().ToString() + ".pdf");

After executing the above example will create a pdf like output1.png file. But I need output like output2.png. Please find two attachments.

Hi Hemadri,

Thanks for using our products.

In order to get the desired behavior, please try using
InlineParagraph approach. I have made slight changes to the code and now the results are as per expectations. Please take a look over the resultant PDF document that I have generated using Aspose.Pdf for .NET 6.3.0.

// Create segment 2 and add it to segments collection of text object
Aspose.Pdf.Generator.Segment seg2 = AnswerText.Segments.Add();
// indicate seg2’s InlineParagraph is a image.
seg2.InlineParagraph = PencilImage;

More along, I have observed
that you are using an older version of Aspose.Pdf for .NET. I would
recommend you to please try using the latest release version. For more
information, please visit the following links.


Thank you very much for you ideas. Its working fine. We will upgrade as ealry as possible.

Thanks