zoukankan      html  css  js  c++  java
  • 写pdf文件

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    
    
    using System.Diagnostics;
    
    using PdfSharp;
    using PdfSharp.Pdf;
    using PdfSharp.Drawing;
    
    namespace imageToPDF
    {
        public partial class FrmPDF : Form
        {
            public FrmPDF()
            {
                InitializeComponent();
            }
    
            private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Close();
            }
    
            private void FrmPDF_Shown(object sender, EventArgs e)
            {
                this.listView1.Columns[0].Width = this.listView1.Width - listView1.Columns[1].Width - listView1.Columns[2].Width;
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
    
                PdfDocument doc = new PdfDocument();
    
                for (int i = 1; i < 13; i++)
                {
                    PdfPage pPdfPage = new PdfPage();
    
                    doc.Pages.Add(pPdfPage);
    
                    string source = @"E:1";
                    if (i < 10)
                    {
                        source = source + "00" + i.ToString() + ".jpg";
                    }
                    else
                    {
                        source = source + "0" + i.ToString() + ".jpg";
                    }
                    XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[i - 1]);
                    XImage img = XImage.FromFile(source);
                    xgr.DrawImage(img, 0, 0);
                }
    
                string destinaton = @"E:11.pdf";
                doc.Save(destinaton);
                doc.Close();
            }
    
            //获得一个文件
            private void 添加图片文件ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string[] FileList = openFileDialog1.FileNames;
                    for (int i = 0; i < FileList.Length; i++)
                    {
                        string FileName = FileList[i];
                        ListViewItem pListViewItem = listView1.Items.Add(FileName);
                        System.IO.FileInfo file = new System.IO.FileInfo(FileName);
    
                        pListViewItem.SubItems.Add((file.Length / 1024).ToString("f0") + "KB");//文件大小
                        pListViewItem.SubItems.Add(file.LastWriteTime.ToString());///最后修改时间
    
    
    
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    OpenCV下载
    ffmpeg.转换示例_处理流程
    调试.pdb&源码
    OpenCV.图片透明
    ffmpeg.用vs2017编译(20200102)
    ffmpeg.视频转码
    ffmpeg.串流_资料(包含一些vlc)
    Qt563x86vs2015.编译错误(TypeError: Property 'asciify' of object Core::Internal::UtilsJsExtension(0x????????) is not a function)
    前端性能优化规则
    前端性能优化 —— reflow(回流)和repaint(重绘)
  • 原文地址:https://www.cnblogs.com/gisoracle/p/6056180.html
Copyright © 2011-2022 走看看