C# winform读写pdf文档哪个好

C# winform读写pdf文档哪个好,第1张

可以使用AdbeRdr器。我们下载一个pdf阅读AdbeRdr器到电脑上,最好是安装完整版的,要不然vs获得到组件,其次,我们就可以在工具箱中获取Adobe提供的Active控件了。

这是代码参考一下,另有附件.

using System

using System.Collections.Generic

using System.ComponentModel

using System.Data

using System.Drawing

using System.Text

using System.Windows.Forms

using System.Xml

 

namespace XMLDemo2

{

    public partial class Form1 : Form

    {

        XmlDocument doc = new XmlDocument()

 

        public Form1()

        {

            InitializeComponent()

 

             

 

            doc.Load("省市区.xml")

 

 

            XmlNode provinces = doc.SelectSingleNode("/ProvinceCity")

            foreach (XmlNode province in provinces.ChildNodes) {

                cbxProvince.Items.Add(province.Name)

            }

            cbxProvince.SelectedIndex = 0

        }

 

        private void cbxProvince_SelectedIndexChanged(object sender, EventArgs e)

        {

            cbxCity.Items.Clear()

 

            string xpath = string.Format("/ProvinceCity/{0}/City", cbxProvince.SelectedItem.ToString())

            XmlNodeList cities = doc.SelectNodes(xpath)

            foreach (XmlNode city in cities) {

                cbxCity.Items.Add(city.Attributes["Name"].Value)

            }

 

            if(cbxCity.Items.Count >= 0) {

                cbxCity.SelectedIndex = 0

            }

        }

 

        private void cbxCity_SelectedIndexChanged(object sender, EventArgs e)

        {

            cbxCityArea.Items.Clear()

 

            string xpath = string.Format("/ProvinceCity/{0}/City[@Name='{1}']/CityArea", 

                    cbxProvince.SelectedItem.ToString(),

                    cbxCity.SelectedItem.ToString())

 

            XmlNodeList CityAreas = doc.SelectNodes(xpath)

            foreach (XmlNode area in CityAreas) {

                cbxCityArea.Items.Add(area.Attributes["Name"].Value)

            }

 

            if(cbxCityArea.Items.Count > 0) {

                cbxCityArea.SelectedIndex = 0

            }

        }

    }

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/7946902.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-11
下一篇 2023-04-11

发表评论

登录后才能评论

评论列表(0条)

保存