This is a migrated thread and some comments may be shown as answers.
HTML to PDF, No CSS and Unable to make landscape
4 Answers 18 Views
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 11 Jun 2019, 01:26 PM

Hi, 

I am looking at the WordsProcessing to use in a project to convert HTML to PDF, however I have two issues. One the CSS from the linked files are not being applied so the first and easy question is must this be inline styles \ css in the cshtml file

 

The second is how do I get the output to show as landscape. My code below shows you how I am currently doing it and it is pushing out the HTML table and data but no styles from bootstrap (mentioned above) but its also very squashed so I need it to be in a landscape format. 

public byte[] ConvertDocumentToPDF(byte[] fileData, string extension, ImageQuality exportQuality)
        {
            byte[] convertedData = null;
 
            RadFlowDocument document;
 
            IFormatProvider<RadFlowDocument> provider = this.providers
                .FirstOrDefault(p => p.SupportedExtensions
                .Any(e => string.Compare(extension, e, StringComparison.InvariantCultureIgnoreCase) == 0));
 
            if (provider == null)
            {
                Log.Error($"No provider found that supports the extension: {extension}");
                return null;
            }
 
            try
            {
                using (Stream stream = new MemoryStream(fileData))
                {
                    try
                    {
                        document = provider.Import(stream);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.ToString());
                        return null;
                    }
                }
 
                var quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Medium;
                switch (exportQuality)
                {
                    case ImageQuality.High:
                        quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.High;
                        break;
 
                    case ImageQuality.Medium:
                        quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Medium;
                        break;
 
                    case ImageQuality.Low:
                        quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Low;
                        break;
                }
 
                PdfFormatProvider formatProvider = new PdfFormatProvider();
                formatProvider.ExportSettings.ImageQuality = quality;
 
                using (var stream = new MemoryStream())
                {
                    formatProvider.Export(document, stream);
                    convertedData = stream.ToArray();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
 
            return convertedData;
        }

 

Any and all help gratefully received. 

 

 

Thanks

 

4 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 12 Jun 2019, 08:11 AM
In addition to the issue above, adding inline css \ pulling out bootstrap 4 css the html table that I have does not display correctly so inline CSS is not working as required either 
0
Boby
Telerik team
answered on 14 Jun 2019, 11:23 AM
Hello Simon,

The CSS standard is not fully supported by the RadWordsProcessing's HTML import, so there is a chance there are some more advanced constructs/selectors that are not imported. Another possible reason could be that HTML is somewhat different from RadWordsProcessing's document model, and not every construct have one on one mapping. Still, I would suggest you to open a support ticket and send us the problematic HTML document for further investigation.

You can also check the Section help article, and especially Rotating a Section and Modifying a Section sections for the possible methods change the section size or orientation, e.g. 
section.Rotate(PageOrientation.Landscape);

Regards,
Boby
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Rui
Top achievements
Rank 1
answered on 14 Dec 2020, 01:29 PM

Hi,

I am also using RadWordsProcessing's to convert HTML to PDF and right now, I'm having a problem with the CSS property "display: inline" on a html list tag (<li> tag).

On the resulting PDF, each element of a list appears on a new line, when all should appear on the same line. This apparently means that the CSS style "display: inline" is being ignored.

The "display: inline" property is not implemented by RadWordsProcessing or it's a bug?

Where can I see a list of all supported (or unsupported) CSS properties?

 

Thanks in advance!

0
Dimitar
Telerik team
answered on 15 Dec 2020, 10:10 AM

Hello Rui,

This is not supported at the moment. I have logged a feature request for it on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here. I have updated your Telerik points as well.  

You can see all the supported HTML features in this article:  Features | Telerik Document Processing.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Simon
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
Boby
Telerik team
Rui
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or