I need to import text from HTML to PPtx using asp.net.
I used AddFromHtml method to add style and text into slide. Color is working fine but background-color and bullet is not working. Please let me know by which way I can implement this.
For example HTML string: "
I have observed the information shared by you and request you to please try using Aspose.Slides for .NET 18.1 on your end. If there is still an issue then please share the source HTML, generated presentation and used sample code. I will investigate the issue further on my end on provision of requested information.
I have tried with upgraded version 18.1, still problem not resolved. its not working for background color and bullets.
I have uploaded code sample, please refer it. CodeSample.PNG (6.1 KB)
I have created an HTML file based on sample image you have provided and it has this HTML view. Please note that Aspose.Slides support only text related tags. In your HTML view, the text, “xyz” is highlighted. Only this highlighted text color is not getting imported in Aspose.Slides paragraph. There is no issue with bullets import as well. Can you please confirm, if this is the only issue occurring on your end.
I have used following sample code on my end using Aspose.Slides for .NET 18.1. Can you please try using the HTML file that I have shared with you and provide the generated presentation file using following code on your end.
public static void ImportHMTL()
{
String path = @"C:\Users\Muhammad\Downloads\testdoc\";
using (Presentation presentation = new Presentation())
{
// Get the first slide
ISlide slide = presentation.Slides[0];
// Add an autoshape of type line
Aspose.Slides.IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 300, 300);
ashape.FillFormat.FillType = FillType.Solid;
ashape.FillFormat.SolidFillColor.Color = Color.Gray;
// Adding text frame to the shape
ashape.AddTextFrame("");
// Clearing all paragraphs in added text frame
ashape.TextFrame.Paragraphs.Clear();
// Loading the HTML file using stream reader
TextReader tr = new StreamReader(path + "testdoc.html");
// Adding text from HTML stream reader in text frame
ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());
presentation.Save(path+"Saved.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
}
Please also share the Operating system and environment details used on your end.
Hi,
I tried this code and this is also not working, one more thing I am not adding new frame, just extracted IAutoframe type from existing template and used their textframe.SavedSlide.PNG (22.3 KB)
It does not matter if you add existing shape text frame or create a new shape with text frame. If you still find issue using shared HTML file and above code sample then please provide a working sample project and generated presentation for reference.