Spire高效稳定的.NET组件

  年末将至,又到了一年一度的收集发票时间,平时零零碎碎的花钱都是不在意开发票,现在好了,到处找发票来报销,简直头大,

                                                                    

东拼西凑,终于搞定了全部发票,大伙多余的发票,麻烦艾特我一下啊,不限日期,能开发票的都可以,谢谢啦。文章后有彩蛋~

这么多的发票,一张一张打印,要浪费我多少时间,就想着合并这些PDF文件(发票)一起打印,节省时间。

还寻思这网上找一个软件来使使,都很(méi)委(līang)婉(xīn)的想收费,在线转PDF的还给我打水印,恰巧今天公司网速不行。

来吧,自己搞!程序猿没有什么不可能!

Spire.PDF

  NPOI、DocX、Epplus……这些开源且免费的优秀组件,大家应该是耳熟能详的,而Spire是一款企业级的收费组件,Spire.PDF for .NET

是一个专业的PDF组件,用于在.NET应用程序中创建,编写,编辑,处理和阅读PDF文件,功能十分丰富…………

提取关键词:收费、稳定、高效 

具体我不再过多的啰嗦了,详细我推荐看这篇《 高效而稳定的企业级.NET Office 组件Spire(.NET组件介绍之二)

合并PDF

  回到今天的问题,合并发票,合并PDF,然后一次性打印。其实吧,主要代码就两行:

1  var doc = PdfDocument.MergeFiles(allFiles.ToArray());
2  doc.Save(DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf", FileFormat.PDF);

然后,你们输出之后会发现,很(méi)漂(līang)亮(xīn)的水印:

“Evaluation Warning:The document was created with Spire.PDF for .NET”

简直玷污我心爱的发票!!!!

解决

  既然隐藏不了,那合并的第一页加入一个空页不就行了?!生成PDF后,然后从第二页开始打印或是删去第一页不就行了?!就这么干!

1             var first = new PdfDocument();
2             first.AppendPage();  //加入一个空页
3             for (int idx = 0; idx < allFiles.Count; idx++)
4             {
5                 var next = new PdfDocument(allFiles[idx]);
6                 first.AppendPage(next); 
7             }
8             first.SaveToFile(DateTime.Now.ToString("yyyyMMddHHmmss")+".pdf", FileFormat.PDF);

                                                                           

需要的下载去用吧。? PDFMerge

工具很简单,就不放到Git上去了,源码:

界面:

namespace 合并PDF
{
    partial class mainForm
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.btnAdd = new System.Windows.Forms.Button();
            this.btnMerge = new System.Windows.Forms.Button();
            this.bgw = new System.ComponentModel.BackgroundWorker();
            this.listView1 = new System.Windows.Forms.ListView();
            this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.progressBar = new System.Windows.Forms.ToolStripProgressBar();
            this.tipStatu = new System.Windows.Forms.ToolStripStatusLabel();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.btnRemove = new System.Windows.Forms.ToolStripMenuItem();
            this.statusStrip1.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // btnAdd
            // 
            this.btnAdd.Location = new System.Drawing.Point(409, 12);
            this.btnAdd.Name = "btnAdd";
            this.btnAdd.Size = new System.Drawing.Size(67, 24);
            this.btnAdd.TabIndex = 2;
            this.btnAdd.Text = "添加文件";
            this.btnAdd.UseVisualStyleBackColor = true;
            this.btnAdd.Click += new System.EventHandler(this.btnSearch_Click);
            // 
            // btnMerge
            // 
            this.btnMerge.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnMerge.Location = new System.Drawing.Point(409, 43);
            this.btnMerge.Name = "btnMerge";
            this.btnMerge.Size = new System.Drawing.Size(67, 24);
            this.btnMerge.TabIndex = 3;
            this.btnMerge.Text = "开始合并";
            this.btnMerge.UseVisualStyleBackColor = true;
            this.btnMerge.Click += new System.EventHandler(this.btnMerge_Click);
            // 
            // bgw
            // 
            this.bgw.WorkerReportsProgress = true;
            this.bgw.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bgw_DoWork);
            this.bgw.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bgw_ProgressChanged);
            this.bgw.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bgw_RunWorkerCompleted);
            // 
            // listView1
            // 
            this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1});
            this.listView1.ContextMenuStrip = this.contextMenuStrip1;
            this.listView1.FullRowSelect = true;
            this.listView1.GridLines = true;
            this.listView1.Location = new System.Drawing.Point(12, 12);
            this.listView1.MultiSelect = false;
            this.listView1.Name = "listView1";
            this.listView1.Size = new System.Drawing.Size(391, 190);
            this.listView1.TabIndex = 4;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.listView1.View = System.Windows.Forms.View.Details;
            // 
            // columnHeader1
            // 
            this.columnHeader1.Text = "文件";
            this.columnHeader1.Width = 350;
            // 
            // statusStrip1
            // 
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.progressBar,
            this.tipStatu});
            this.statusStrip1.Location = new System.Drawing.Point(0, 205);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(488, 22);
            this.statusStrip1.TabIndex = 5;
            this.statusStrip1.Text = "statusStrip1";
            // 
            // progressBar
            // 
            this.progressBar.Name = "progressBar";
            this.progressBar.Size = new System.Drawing.Size(100, 16);
            // 
            // tipStatu
            // 
            this.tipStatu.Name = "tipStatu";
            this.tipStatu.Size = new System.Drawing.Size(27, 17);
            this.tipStatu.Text = "0/0";
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.btnRemove});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(101, 26);
            // 
            // btnRemove
            // 
            this.btnRemove.Name = "btnRemove";
            this.btnRemove.Size = new System.Drawing.Size(180, 22);
            this.btnRemove.Text = "移除";
            this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
            // 
            // mainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(488, 227);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.listView1);
            this.Controls.Add(this.btnMerge);
            this.Controls.Add(this.btnAdd);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MaximumSize = new System.Drawing.Size(504, 266);
            this.MinimumSize = new System.Drawing.Size(504, 266);
            this.Name = "mainForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "PDF Merge";
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion
        private System.Windows.Forms.Button btnAdd;
        private System.Windows.Forms.Button btnMerge;
        private System.ComponentModel.BackgroundWorker bgw;
        private System.Windows.Forms.ListView listView1;
        private System.Windows.Forms.ColumnHeader columnHeader1;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripProgressBar progressBar;
        private System.Windows.Forms.ToolStripStatusLabel tipStatu;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.ToolStripMenuItem btnRemove;
    }
}
View Code

后台:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using Spire.Pdf;
using System.Threading;

namespace 合并PDF
{
    public partial class mainForm : Form
    {
        public mainForm()
        {
            InitializeComponent();
        }

        List<string> allFiles = new List<string>();
        private void btnSearch_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.Filter = "PDF文件|*.pdf";
            openFile.Multiselect = true;
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                foreach (var fi in openFile.FileNames)
                {
                    if (allFiles.Contains(fi))
                        continue;
                    this.listView1.Items.Add(new ListViewItem(fi));
                    allFiles.Add(fi);
                }
                progressBar.Minimum = 0;
                progressBar.Maximum = allFiles.Count;
            }
        }
        private void btnMerge_Click(object sender, EventArgs e)
        {
            if (!bgw.IsBusy)
            {
                if (allFiles.Count<=1)
                {
                    MessageBox.Show("请至少选择 2 个PDF文件");
                    return;
                }
                CtrlStatu(false);
                bgw.RunWorkerAsync();
            }
        }

        private void CtrlStatu(bool b)
        {
            listView1.Enabled = b;
            btnMerge.Enabled = b;
            btnAdd.Enabled = b;
        }

        private void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            var first = new PdfDocument();
            first.AppendPage();  //加入一个空页
            for (int idx = 0; idx < allFiles.Count; idx++)
            {
                var next = new PdfDocument(allFiles[idx]);
                first.AppendPage(next);
                ReportInfo(idx + 1, allFiles.Count);
                Thread.Sleep(100);
            }
            first.SaveToFile(DateTime.Now.ToString("yyyyMMddHHmmss")+".pdf", FileFormat.PDF);
        }

        /// <summary>
        /// 输出消息
        /// </summary> 
        public void ReportInfo(int idx,int count)
        {
            bgw.ReportProgress(1, idx + "/" + count);
        }

        private void bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            var userState = e.UserState.ToString();
            tipStatu.Text = userState;
            progressBar.Value = Convert.ToInt32(userState.Split('/')[0]);
        }

        private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            tipStatu.Text = "合并完成...";
            CtrlStatu(true);
        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count > 0)
            {
                int idx = this.listView1.SelectedItems[0].Index;
                allFiles.Remove(this.listView1.SelectedItems[0].Text);
                this.listView1.Items[idx].Remove();
            }
        }
    }
}
View Code

 

转载于:https://www.cnblogs.com/EminemJK/p/10298684.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spire.BarCode for .Net 是一款专业的免费条形码组件,专为.NetC#, VB.NET, ASP.NET)开发人员设计,用于生成和读取一维和二维条形码。使用Spire.BarCode,开发编程人员可以迅速轻松地为.Net应用软件(ASP.NET, WinForms and Web Service)嵌入企业级的条形码功能。 Spire.BarCode提供了一个非常简单的方法来集成条形码处理功能。一行代码就可以生成、读取一维和二维条形码。Spire.BarCode支持包括Bitmap, JPG, PNG, EMF, TIFF, GIF and WMF等众多常用的图片格式。 主要功能: 1.强大的一维、二维条形码识别和生成功能 支持常用的线性条形码,二维条形码,邮政条形码,能从任何方向检测这些条形码。 2.高效生成和读取条形码图像 开发人员可根据需求创建Bitmap, JPG, PNG, EMF, TIFF, GIF and WMF等格式的条形码图像。 3.支持读取和编辑条形码,性能优越 开发人员可轻松地设置条形码图像的边框类型,边框颜色,样式,边距和宽度。同时,可以按任何角度旋转并生成高质量的条形码图像。 4.整合便捷 Spire.BarCode for .Net 可以被集成到任何.Net应用程序中,操作简单。有两种集成模式:API模式和组件模式  1) API模式仅使用一行代码即可创建和识别条形码  2) 组件模式使用可视化方式来创建条形码,随后将Spire.BarCode组件拖入.Net Windows或 ASP.NET Form中。 无需其他代码。 5.支持30多种不同类型的条形码。 友情提示:Spire.BarCode本身免费,如需商用或需去除E-iceblue的logo,请至http://www.e-iceblue.com/Download/download-barcode-for-net-now.html查看获得Key的方式
### 回答1: SAP的委外订单组件底表是指在SAP系统中用于管理委外订单的数据表格。委外订单是指将公司的某些业务活动或生产过程委托给外部供应商来完成的一种业务模式。 底表是数据库中的一个特定表格,用于存储相关数据并提供查询和分析功能。在SAP中,委外订单组件底表包括了与委外订单相关的各种信息。这些信息通常包括订单编号、物料编号、供应商编号、订单数量、交货日期等。 委外订单组件底表的主要作用是记录和跟踪委外订单的执行情况。通过对底表数据的分析,可以方便地查看委外订单的详细信息,如订单数量是否满足预期、供应商的交货是否准时,以及订单是否按照预定时间完成等。 底表还可以用于生成统计报表和进行数据分析。通过对委外订单组件底表中的数据进行汇总和分析,可以得到一些有价值的洞察,比如哪些供应商的交货质量更好,哪些订单执行效率较低等。这些信息对于优化供应链管理和提高采购决策的效率都非常有帮助。 总之,SAP的委外订单组件底表是一个用于存储和管理委外订单数据的数据库表格。通过底表,可以方便地追踪和分析委外订单的执行情况,为企业的供应链管理和采购决策提供有力的支持。 ### 回答2: SAP委外订单组件底表是指在SAP系统中委外订单模块所使用的底层数据表。委外订单是指企业外部委托供应商或合作伙伴进行加工或生产某些产品的订单。这些底表用于存储和管理与委外订单相关的各种数据。 常见的SAP委外订单组件底表包括: 1. EKPO表:该表用于存储委外采购订单的采购项目数据,包括物料号码、数量、价格等信息。 2. EKKO表:该表保存了委外采购订单的基本数据,如采购组织、供应商、采购日期等。 3. EKBE表:该表用于跟踪委外采购订单的货币流转和库存变化情况,记录了物料的入库、出库和结算等关键信息。 4. RESB表:该表保存了委外订单的需求计划数据,包括物料需求量、需求日期等。 5. AFPO表:该表用于存储委外订单的生产任务数据,包括订单数量、生产工序等信息。 6. AFVC表:该表用于记录委外订单的生产工序流程,包括工序顺序、工序类型等。 这些底表的配套使用可以帮助企业进行委外订单的有效管理和跟踪,实现供应链的透明化和协同合作。通过SAP委外订单组件底表,企业可以实时掌握委外订单的状态、成本和交货情况,加强对供应商和合作伙伴的监控和管理,提高生产计划和交货准确性,从而提升企业的运营效率和竞争力。 ### 回答3: SAP委外订单组件底表是SAP系统中用于存储委外订单相关信息的表格结构。委外订单是企业委托外部供应商或合作伙伴来完成特定生产或加工任务的一种采购方式。 底表是指SAP系统中存储数据的表格结构。SAP委外订单组件底表通常包括以下字段: 1. 委外订单号:用于唯一标识委外订单的编号。 2. 委外供应商:记录执行委外任务的供应商或合作伙伴的相关信息。 3. 物料编号:表明委外订单涉及的物料的编号。 4. 数量:表示委外订单中所需的产品数量。 5. 单位:描述委外订单中物料数量的计量单位。 6. 委外合同:如果委外订单与某个委外合同相关联,该字段记录合同信息。 7. 订单状态:表示委外订单的当前处理状态,如进行中、已完成等。 8. 交付日期:记录委外订单的交付日期。 委外订单组件底表的作用是方便企业对委外订单进行管理和跟踪。通过底表中的字段,企业可以了解委外订单的具体内容、相关供应商信息和执行状态,以便及时调整生产计划和跟踪交付进度。 对于SAP系统中的委外订单组件底表,企业可以通过相关的SAP模块或功能来对其进行操作和查询,帮助企业实现高效的委外采购管理。例如,可以通过SAP的采购订单管理模块来创建、修改和审核委外订单,并可以通过物料需求计划(MRP)功能来进行物料需求计划的调整和生成相关的委外订单。 总之,SAP委外订单组件底表对于企业来说是一个重要的管理工具,帮助企业实现对委外订单的有效管理和控制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值