-
Notifications
You must be signed in to change notification settings - Fork 6
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
I would love to use this from WinForms/GDI+ #2
Comments
Ok, I've got GDI+ mostly working. I'll be issuing a PR once I get it fully working. For now, the biggest problem I have is how
Here's the problem: When I do this and yPos is 0, the page background, drawn by
...gets callled with 0, 0, width, FULL HEIGHT OF HTML DOC. IOW, Then, when I'm printing page 2, yPos is See image.
This is what I can't figure out. Why is ScrollOffset negative? Why does the background draw incorrectly, yet the text draw where I expect it? |
I recall some difficulty in getting ViewPort to render correctly on Mac and WPF. My suspicion is that your implementation may not be setting the
LiteHtmlSharp/LiteHtmlSharp.Mac/LiteHtmlWindowHelper.cs Lines 44 to 48 in 3f4db0f
IIRC the C++ litehtml API expects the the scroll offset to be negative, while most GUI framework scrollviews use positive numbers -- so the C# layer performs a coord invert to make implementations easier. If you open a draft PR then I may be able to help debug. |
I'll try to get a draft PR going. My app is pretty besopke and I never built a Example.WinForms, which I should have. Knowing litehtm uses negative numbers for the scroll offset for sure helps (I actually noted the I'll keep you posted. This framework has put me on a path with this app that I really think will work well and I'm pretty excited. I had tried using CEF/Chromium and spent weeks struggling to trick it into rendering where I wanted it. With I'm not sure LiteHtmlSharp/LiteHtmlSharp/ViewportContainer.cs Lines 74 to 78 in 3f4db0f
LiteHtmlSharp/LiteHtmlSharp/Document.cs Lines 78 to 82 in 3f4db0f
I'm doing this: int width = (int)PageSize.Width;
int height = (int)PageSize.Height;
Debug.WriteLine($"HtmlFileContent.CountPages - Page size: {width}x{height} @ {printerResolution.X}x{printerResolution.Y} dpi");
int bestWidth = litehtml.Document.Render((int)width);
Debug.WriteLine($"Litehtml_DocumentSizeKnown {litehtml.Document.Width()}x{litehtml.Document.Height()} bestWidth = {bestWidth}"); Which gets me I've confirmed that litehmtl's |
Thats great!
This sounds reasonable. I think I recall litehtml giving rendering instructions that extend past the visible content area. |
FWIW, I'm pretty close to having this work as well as it's going to on Windows. I'm now working to get the app running under Linux as well. I can't get I found that libgdiplus (under |
The app that uses this is now available as an 'alpha'. In case you're curious... https://github.com/tig/winprint I have a nasty bug in my GDI+ Document Container in whitepace and empty tag sizing tho. See tig/winprint#14 I'm sure I'm doing something stupid. |
I've got it building and running via VS2019 and the WPF sample. It does not look hard to port the WPF sample to WinForms/GDI+, but if someone's already done it, that'd be trick.
If not, any advice on how to proceed that might save me some time.
The text was updated successfully, but these errors were encountered: