Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with window size when converting to Image #190

Open
daniherculano84 opened this issue Feb 24, 2025 · 0 comments
Open

Problem with window size when converting to Image #190

daniherculano84 opened this issue Feb 24, 2025 · 0 comments
Assignees
Labels

Comments

@daniherculano84
Copy link

daniherculano84 commented Feb 24, 2025

Hi,
I used to convert with version 2.6.7 but since last chrome updates and headless braking changes, I updated to 4.3.2. My issue is that I want an html to be converted to full-hd resolution image (not pdf) but the final resolution is a bit shorter. It seems like if browser is opened containing the html inside typical frame and header.

using (var converter = new Converter())
  {
      input = @"C:/ProgramData\SignageServidor\temp\20250113124855753\index.html";
      output = @"C:/ProgramData\SignageServidor\clientes\afbe740d-3fd8-456c-6b4f-08d69bdfa22c\previews\1111.jpg";
      width = 1920;
      height = 1080;
      ConvertUri uri = new ConvertUri(input);

      var chromeSett = new ChromiumHtmlToPdfLib.Settings.PageSettings { };

      converter.EnableChromiumLogging = true;

      //converter.AddChromiumArgument("--disable-features=PrintCompositorLPAC");
      //converter.ResetChromiumArguments();
      //converter.AddChromiumArgument("--screenshot");
      converter.AddChromiumArgument("--headless");

      converter.SetWindowSize(width, height);

      converter.ConvertToImage(uri, output, chromeSett);
  }

The image result has 1904x933 pixels. It doesn't matter if I'm passing --headless or not.
I could fix it by increasing the WindowSize adding the lost pixels until I get Full-HD on image converted but I don't like this workaround
(Window size = 1936x1227 gets FHD image)

Any idea?

Logs:

info: Starting Google Chrome from location 'C:\Program Files\Google\Chrome\Application\chrome.exe' with working directory 'C:\Program Files\Google\Chrome\Application'
info: "C:\Program Files\Google\Chrome\Application\chrome.exe" --headless --block-new-web-contents --hide-scrollbars --disable-domain-reliability --disable-sync --mute-audio --disable-background-networking --disable-background-timer-throttling --disable-default-apps --disable-extensions --disable-hang-monitor --disable-prompt-on-repost --metrics-recording-only --no-first-run --no-default-browser-check --enable-automation --no-pings --noerrdialogs --run-all-compositor-stages-before-draw --remote-debugging-port="0" --window-size="1920,1080"
info: Google Chrome process started
fail: Received Chromium error data: 'DevTools listening on ws://127.0.0.1:55923/devtools/browser/885120b0-487b-46b2-b948-df4a647bfedf'
info: Connecting to dev protocol on uri 'ws://127.0.0.1:55923/devtools/browser/885120b0-487b-46b2-b948-df4a647bfedf', got uri from data received from error stream
info: Creating new websocket connection to url 'ws://127.0.0.1:55923/devtools/browser/885120b0-487b-46b2-b948-df4a647bfedf'
info: Opening websocket connection with a timeout of 30000 milliseconds
info: Websocket opened
info: Creating new websocket connection to url 'ws://127.0.0.1:55923/devtools/page/C71BF51CCAEAD506D420CE02BF63F44D'
info: Opening websocket connection with a timeout of 30000 milliseconds
info: Websocket opened
info: Connected to dev protocol
info: Google Chrome started
info: Loading file C:/ProgramData\SignageServidor\temp\20250113124855753\index.html
info: Enabling caching
info: Enabling page domain notifications
info: Enabling page lifecycle events
info: Navigating to url 'file:///C:/ProgramData/SignageServidor/temp/20250113124855753/index.html'
info: The 'Page.frameNavigated' event has been fired, waiting for the 'Page.lifecycleEvent' with name 'networkIdle'
info: The 'Page.lifecycleEvent' with param name 'DOMContentLoaded' has been fired, the dom content is now loaded and parsed, waiting for stylesheets, images and sub frames to finish loading
info: The 'Page.loadEventFired' event has been fired, the page is now fully loaded
info: File loaded
info: Converting to image
info: Converted
info: Image written to output file 'C:/ProgramData\SignageServidor\clientes\afbe740d-3fd8-456c-6b4f-08d69bdfa22c\previews\2222.jpg'
info: Closing Google Chrome browser gracefully
info: Disposing websocket connection to url 'ws://127.0.0.1:55923/devtools/page/C71BF51CCAEAD506D420CE02BF63F44D'
info: Disposing websocket connection to url 'ws://127.0.0.1:55923/devtools/browser/885120b0-487b-46b2-b948-df4a647bfedf'
info: Google Chrome closed gracefully
@Sicos1977 Sicos1977 self-assigned this Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants