r/visualbasic • • Jul 20 '24

VB.NET Help Rendering Conversion of Excel file to PDF and Showing it into PDF Viewer

So I am doing a document printing kiosk using VB.net 8.0, and i am at the point where when you click a excel file it would be converted into a pdf file then it would load a form where it contain a pdf viewer where you can see a preview of you file and its page number, file name etc before you can go and print it, the problem is when i click the excel file it does not fit the PDF Viewer, but when i open the converted file as pdf directly it is showing as intended, i think may it is rendering issue?

4 Upvotes

11 comments sorted by

View all comments

Show parent comment

4

u/jd31068 Jul 21 '24

I've actually never used it before; I just like to try to help here and there where I think I might be able to. That being said this WebView2 fit to page - Microsoft Q&A has an answer of

webView21.CoreWebView2.ExecuteScriptAsync("document.body.style.zoom = 'fit-to-width';")

Add that inside the if statement handling the hiding of the icons on the toolbar, I tested it, and it works. Anything you can do with a PDF in MS Edge is possible in the WebView2 control, including running JavaScript to modify the page being displayed and Edge's PDF capabilities are really good.

2

u/Time-Lavishness95 Jul 21 '24

thanks a lot man! you're a lifesaver!

3

u/jd31068 Jul 21 '24

You're welcome, happy to lend a hand. Good luck with the rest of your project.