C# PDF文件不是';t在Windows窗体的webBrowser控件中居中
我正在尝试制作一个PDF实用程序应用程序,允许用户合并和拆分PDF文件。我现在唯一的问题是,我的应用程序在加载时显示的pdf文件偏离中心。例子 为了使PDF文件居中,我必须手动用鼠标单击PDF文件偏离中心时显示的深灰色区域。之后,pdf文件将像这样居中 那么,是否有可能使PDF文件像第二幅图像一样自动居中 下面的代码是如何调用呈现pdf文件的webBrowser1C# PDF文件不是';t在Windows窗体的webBrowser控件中居中,c#,.net,winforms,pdf,itext,C#,.net,Winforms,Pdf,Itext,我正在尝试制作一个PDF实用程序应用程序,允许用户合并和拆分PDF文件。我现在唯一的问题是,我的应用程序在加载时显示的pdf文件偏离中心。例子 为了使PDF文件居中,我必须手动用鼠标单击PDF文件偏离中心时显示的深灰色区域。之后,pdf文件将像这样居中 那么,是否有可能使PDF文件像第二幅图像一样自动居中 下面的代码是如何调用呈现pdf文件的webBrowser1 public Form1() { InitializeComponent(); str
public Form1()
{
InitializeComponent();
string filename = "pdf_example.pdf";
string path = Path.Combine(Environment.CurrentDirectory, filename); // grab pdf file from root program file
webBrowser1.Url = new Uri(path); // <-- input pdf location, WebBrowser Code section, REDACTED
//"button1" == "Load PDF Files", EventHandler
button1.Click += new EventHandler(button1_click);
//"button2" == "Save PDF Files", EventHandler
button2.Click += new EventHandler(button2_click);
//"button3" == "Merge PDF Files", EventHandler
button3.Click += new EventHandler(button3_click);
//"button4" == "Split PDF Files", EventHandler
button4.Click += new EventHandler(button4_click);
}
public Form1()
{
初始化组件();
string filename=“pdf_example.pdf”;
string path=path.Combine(Environment.CurrentDirectory,filename);//从根程序文件获取pdf文件
webBrowser1.Url=新Uri(路径);//供将来参考。问题是我的监视器分辨率设置为4k。这导致pdf文件由于某种原因每次都在IE中以偏心的方式打开。如果程序是在分辨率为1920x1080的监视器中打开的,则每次程序启动时pdf文件都完全居中。供将来参考。问题是我的监视器分辨率设置为4k。由于某种原因,这导致每次在IE中pdf文件都会偏离中心打开。如果程序是在分辨率为1920x1080的监视器中打开的,则每次程序启动时pdf文件都会完全居中
void Form1_Shown(object sender, EventArgs e)
{
string filename = "pdf_example.pdf";
string path = Path.Combine(Environment.CurrentDirectory, filename); // grab pdf file from root program file
webBrowser1.Url = new Uri(path); // <-- input pdf location, WebBrowser Code section, REDACTED
}