Is there a way to add authentication header to the image requests that are in the html.??? Currently the document includes the images from the image src defined in Html as long as authentication header is not needed. Could you help me with the code.??
//this is my converter method
public List<byte[]> Convert(ContentsDto content, IDictionary<string, string> options, System.Func<DependentContent, Task<ContentsDto>> GetDependency = null)
{
var pdfBytearray = new List<byte[]>();
License htmlLicense = new License();
//authentication
WebClient webClient = new WebClient();
AssetteAuthenticationHelper assetteAuthenticationHelper = new AssetteAuthenticationHelper(_authSettings, _settingsProvider.User.UserId, _settingsProvider.User.ClientId);
var token = assetteAuthenticationHelper.GetAuthToken();
webClient.Headers.Add("Authorization", $"Bearer {token}");
using (var streamProvider = new MemoryStream(content.Data))
{
//convert html to pdf
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions() { HtmlMediaType = HtmlMediaType.Print };
Document pdfDocument = new Document(streamProvider, htmlLoadOptions );
//convert pdf to pptx
PptxSaveOptions pptx_save = new PptxSaveOptions();
using (var pptxStream = new MemoryStream())
{
pdfDocument.Save(pptxStream, pptx_save);
pptxStream.Seek(0, System.IO.SeekOrigin.Begin);
pdfBytearray.Add(pptxStream.ToArray());
}
}
return pdfBytearray;
}