PDF文件不在Windows窗体的webBrowser控件中居中

问题描述 投票:1回答:1

我正在尝试制作一个PDF实用程序应用程序,该应用程序将允许用户合并和拆分PDF文件。我现在唯一的问题是在加载时我的应用显示pdf文件偏离中心。例“

为了使PDF文件居中,我必须手动鼠标单击PDF文件偏离中心时显示的深灰色区域。之后,pdf文件将像这样居中““>

因此,是否有可能使PDF文件像第二张图像一样自动居中?

下面的代码是我如何调用呈现pdf文件的webBrowser1。

 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);

    }

我以为这与在完全加载Form1窗口之前加载pdf有关。因此,我尝试制作一个方法,并将Form1 Shown属性设置为此方法。

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  

    }

没有用。

任何帮助将不胜感激。

[我也完全重做了该应用程序,以使用axAcroPDF控件呈现PDF而不是使用webBrowser控件呈现PDF,但仍然遇到PDF文件偏离中心的问题。

我正在尝试制作一个PDF实用程序应用程序,该应用程序将允许用户合并和拆分PDF文件。我现在唯一的问题是在加载时我的应用显示pdf文件偏离中心。示例为了...

c# .net winforms pdf itext
1个回答
0
投票

供将来参考。问题是我的显示器分辨率设置为4k。由于某种原因,这导致pdf文件每次都在IE中偏离中心。如果程序是在1920x1080分辨率的监视器中打开的,则每次程序启动时pdf文件都会完美居中。

© www.soinside.com 2019 - 2024. All rights reserved.