It seems like you've already taken the correct steps to ensure that Chrome renders the page in a desktop view by specifying the --window-size and --user-agent flags. However, if it's still rendering as mobile, you might want to explicitly add the --disable-device-emulation flag to your command. This flag is not actually available in Chrome command-line switches, but ensuring that no mobile emulation is being triggered could be the key.
Here's an updated version of your command with some additional flags that might help:
$command = sprintf(
'%s --headless --disable-gpu --no-sandbox --print-to-pdf=%s --window-size=1920,1080 --force-device-scale-factor=1 --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" --disable-mobile-emulation --force-device-scale-factor=1 --disable-built-in-pdf-viewer %s',
escapeshellcmd($chromePath),
escapeshellarg($tempPdfFile),
escapeshellarg($tempHtmlFile)
);
Please note that I've added --disable-built-in-pdf-viewer to ensure that Chrome doesn't try to use its built-in PDF viewer, which could potentially affect the rendering.
If this doesn't solve the issue, you might want to check if there's any CSS or JavaScript within your HTML content that could be forcing a mobile view. Sometimes, media queries or JavaScript code can alter the rendering based on the perceived device width or user agent.
Also, ensure that your HTML does not have any viewport meta tags that force mobile rendering, such as:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
If this tag is present, try removing it or adjusting it to suit a desktop view:
<meta name="viewport" content="width=1920">
Lastly, if none of these solutions work, you might want to try using a different tool for rendering the PDF, such as Puppeteer, which provides a higher level of control over the headless Chrome instance and might give you better results.