Free Support Forum - aspose.com

Missing text and images converting html to xps

Hi,

I'm having an issue when I trying to convert a html file to xps, the issue is basically that part of the text is missing into the xps, in other words, the xps file does not show all the text and images from html file, and if I try with a print preview, I'm able to see all the information of the html file,

I would like to know if there any property that I have to set to the convertion, or I'm doing something wrong, this is the code that I'm using:

Document doc = new Document(htmlPath, new LoadOptions() { LoadFormat = LoadFormat.Html });

foreach (Section section in doc.Sections)

{

section.PageSetup.PaperSize = PaperSize.Letter;

section.PageSetup.TopMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.BottomMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.LeftMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.RightMargin = ConvertUtil.InchToPoint(0.5);

}

doc.Save(xpsPath, SaveFormat.Xps);

Thanks,

Regards,

Hi

Thanks for your request. Could you please attach your input and output documents here for testing? We will check the issue and provide you more information.

Best regards,

Hi,

Here are the examples,

Best Regards,

Thanks,

Hi

Thank you for additional information. But I do not see that some content is lost upon converting your HTML documents to XPS. I used the following code for testing:

Document doc = new Document(@"Test001\input3.html");

foreach (Section section in doc.Sections)

{

section.PageSetup.PaperSize = PaperSize.Letter;

section.PageSetup.TopMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.BottomMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.LeftMargin = ConvertUtil.InchToPoint(0.5);

section.PageSetup.RightMargin = ConvertUtil.InchToPoint(0.5);

}

doc.UpdateTableLayout();

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);

foreach (Table table in tables)

{

FitTableToPageWidth(table);

}

doc.Save(@"Test001\out.xps");

You can find FitTableToPageWidth method here:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-autofit-a-table-to-page-width.html

Unfortunately, the output XPS does not look exactly as your HTML in browser. This can be explained that Aspose.Words was originally designed to work with MS Word documents. That is why upon processing HTML some features of HTML might be lost.

Best regards,

Thanks for everything, this implementation solve the issue that I have been trying to fix.

Best Regards,
Thanks,