Cannot add an image after the floating box

Hi, I got an exception when adding an image after a floating box which has two images in it.

Now I am using Aspose.PDF 9.9, the sample code is below:

var pdf = new Pdf();
const string webImgUrl = @“https://www.google.co.nz/images/srpr/logo11w.png”;
var section = pdf.Sections.Add();
var webImg = new Image { ImageInfo = { File = webImgUrl, ImageFileType = ImageFileType.Png, FixHeight = 800 } };
var floatingBox = new Aspose.Pdf.Generator.FloatingBox();
floatingBox.Paragraphs.Add(webImg);
floatingBox.Paragraphs.Add(webImg);
section.Paragraphs.Add(floatingBox);
section.Paragraphs.Add(webImg);
//pdf.Save(@“C:\temp\Image_Error.pdf”);
using (var stream = new MemoryStream())
{
pdf.Save(stream);
using (var fileStream = File.Open(@“C:\temp\Image_Error.pdf”, FileMode.Create))
stream.CopyTo(fileStream);
}

Thanks

Hi Patrick,

Thanks for your inquiry. Please use new DOM approach for the scenario, it successfully adds an image after FloatingBox. However, I have noticed that the second image in the floating box is not rendering correctly. So, I logged a ticket PDFNEWNET-39067 for further investigation and rectification. We will notify you as soon as it is resolved.

var pdf = new Aspose.Pdf.Document();
const string webImgUrl = @"https://www.google.co.nz/images/srpr/logo11w.png";
var section = pdf.Pages.Add();

var img = new Image();

var webImg = new Aspose.Pdf.Image
{
    File = webImgUrl,
    FixHeight = 800
};

var floatingBox = new Aspose.Pdf.FloatingBox();
floatingBox.IsNeedRepeating = true;
floatingBox.Paragraphs.Add();
floatingBox.Paragraphs.Add(webImg);
floatingBox.Paragraphs.Add(webImg);
floatingBox.Paragraphs.Add(section.Paragraphs.Add(floatingBox));
floatingBox.Paragraphs.Add(section.Paragraphs.Add(webImg));

//pdf.Save(@"C:\temp\Image_Error.pdf");
using (var stream = new System.IO.MemoryStream())
{
    pdf.Save(stream);

    using (var fileStream = System.IO.File.Open(@"C:\temp\Image_Error.pdf", System.IO.FileMode.Create))
    {
        stream.CopyTo(fileStream);
    }
}

We are sorry for the inconvenience caused.

Best Regards,

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


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