You’re trying to convert a webpage to PDF, but some images are missing in the final document—particularly images that should appear on scroll or load dynamically.
Why Images Go Missing
This issue often occurs when a website uses lazy loading for images. Lazy loading delays image loading until they are needed (e.g., when you scroll), but this behavior is not supported by PDF.co’s conversion engine by default.
How to Fix Missing Images
To ensure images load properly in the PDF, you can execute a custom JavaScript snippet before conversion. This can help force image loading before the PDF is generated.
Example: Use JavaScript to Modify the Page Before Conversion
You can use the /pdf/convert/from/url endpoint and include a custom script like this:
API Request Sample:
POST https://api.pdf.co/v1/pdf/convert/from/url
Body:
{
"url": "https://www.alomone.com/p/anti-cav1-2-antibody/ACC-003?go=coa",
"customScript": "document.querySelectorAll('a').forEach(a => { a.href = '#' });"
}
You can replace the customScript
content with your own script that ensures lazy-loaded images are forced to load.
Platform-Specific Related Resources
Helpful Tips
Use
"customScript"
to manipulate elements before rendering.Test the script in a browser console first to ensure it behaves as expected.
For large or slow-loading pages, use
"async": true
and monitor job status for best results.