0

Using SelectPDF Html to PDF Converter. Generally working fine to convert a fairly complex HTML string (rendered from a razor view) to a pdf document. I am encountering one strange issue related to img tags. The images are appearing in the PDF, however they are not appearing in full resolution/color. They end up (in the PDF) in some sort of transparent fashion (colors are muted). See attached screen shot for code snippet and resulting PDF (shows the pdf img rendering along with the original html that shows how the img should look) enter image description here

elitz
  • 51
  • 3

2 Answers2

0

You can try the below code before calling the converter.ConvertHtmlString() method.

foreach (PdfElement element in converter.Options.WebElementsMappingOptions.Result)
{
  if (element is PdfImageElement)
  {
    element.Transparency = 100;
  }
}

This will set the image element transparency to completely opaque.

Refer here for more

  • Unfortunately this did not work for me. I have abandoned use of footers and headers for now – elitz Jan 22 '23 at 11:43
0

Found a work around for now. Instead of using approach, i converted my jpg image into an SVG element and replaced the with an element. Found several mic converters that reasonably convert jpg to svg output. The svg element seems to work fine in the pdf header section and does not suffer from the same semi-transparent issue that jpg's encountered.

elitz
  • 51
  • 3