[Ultimate PDF] Redirect in img src causes image not to render
Reactive icon
Forge component by Leonardo Fernandes
Application Type


We are using a headless content management system (Contentful) and rendering documents from the repository in HTML. We use the Ultimate PDF PrintToPdf_Advanced method to print the documents to PDF. Some of the document components in the repository are not secured (like images); these can be fetched without any repository credentials. To get around this we created a service to fetch an image using a signed URL. Any images embedded in the document have the img src attribute point to the service which creates the signed URL for the image then executes a redirect to the signed URL. This works fine in HTML but when creating the PDF, the image does not appear. We can see our service being called and it sets up the redirect to the signed URL correctly but we suspect that the redirect is being blocked in the PrintToPdf_Advanced method. If we use the unsecured image URL in the img src attribute (without the redirect), it prints correctly.

Is there a way to diagnose whether the redirect is being blocked, and if so, can you suggest a workaround?

Thanks very much.

Hi Bruce,

UltimatePDF uses a headless browser to render the html and the session is not shared for that headless browser instance. We need to pass the session cookies explicitly.  this may be the reason for your secured image url not working.

Hi Bruce. Were you able to overcome this issue?

I will test this scenario and see if I detect anything wrong.

I could not find any issues with image redirects.

When rendering headers/footers, Ultimate PDF creates one clone of these elements per page (using headerEl.cloneNode(true)). Maybe for some reason, when creating the clones, the image becomes invalid? It shouldn't because, as long as the src of the cloned image is exactly the same as the original, the browser should avoid a network request and just reuse the same image file.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.