Telerik PdfFormatProvider export throwing exception when <Img /> tag included in HTML

0 Answers 78 Views
PdfProcessing
Pravin
Top achievements
Rank 1
Pravin asked on 03 Mar 2023, 01:45 PM

Dear Telerik Team,

We encounter an issue with export html data to pdf file using below code. For example,

using Telerik.Web.UI;

using OpenXmlSpreadsheet = DocumentFormat.OpenXml.Spreadsheet;
using Pdf = Telerik.Windows.Documents.Flow.FormatProviders.Pdf;
using te = Telerik.Windows.Documents.Flow.FormatProviders.Html;
using tm = Telerik.Windows.Documents.Flow.Model;
using tp = Telerik.Windows.Documents.Primitives;
using tt = Telerik.Windows.Documents.Spreadsheet.Theming;te.HtmlFormatProvider provider = new te.HtmlFormatProvider();

tm.RadFlowDocument document = provider.Import(HttpUtility.HtmlDecode(htmldata));
tt.ThemeFontScheme fs = new tt.ThemeFontScheme("Arial", "Helvetica", "sans-serif");
tt.DocumentTheme theme = new tt.DocumentTheme("PDF", document.Theme.ColorScheme, fs);
document.Theme = theme;
document.Sections[0].PageMargins = new tp.Padding(50, 25, 50, 25);
Pdf.PdfFormatProvider providerPdf = new Pdf.PdfFormatProvider();
byte[] fileBytes = providerPdf.Export(document);

 

"providerPdf.Export(document);" this line throws exception "An exception occurred during a WebClient request" whenever we include <img src="/image path/image.png" /> html tag.

Your support is appreciated.

 

 

Dimitar
Telerik team
commented on 06 Mar 2023, 07:42 AM

Hi Pravin,

Can you provide the exact exception along with the call stack?

If you are using the Net Standard version you need to add a default ImagePropertiesResolver. Detailed information is available here: PdfProcessing - Images - Telerik Document Processing

I am looking forward to your reply.

Regards,

Dimitar

No answers yet. Maybe you can help?

Tags
PdfProcessing
Asked by
Pravin
Top achievements
Rank 1
Share this question
or