zoukankan      html  css  js  c++  java
  • C# 生成PDF

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Collections;
    //
    using iTextSharp;//下载这个DLL即可
    using iTextSharp.text;
    using iTextSharp.text.pdf;

    namespace PDFGenerator
    {
        class Program
        {

            static void Main(string[] args)
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream("e://test1.pdf", FileMode.Create));
                //生成的PDF文件名为test1.pdf
                document.Open();
                BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                //对齐方式:cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                //下划线:Chunk chunk1 = new Chunk("This text is underlined", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE));
                //删除线:Chunk chunk2 = new Chunk("This font is of type ITALIC | STRIKETHRU", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC | Font.STRIKETHRU));
                Font fontChinese = new Font(bfChinese, 14, Font.UNDERLINE, Color.RED);
                //Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, new Color(0, 0, 0));//黑
                //Font fontChinese = new Font(bfChinese, 12, Font.NORMAL,new Color(0, 255, 0)); //绿
                document.Add(new Paragraph("你好,world", fontChinese));
                //向PDF添加TextBox1的内容
                iTextSharp.text.Image jpeg = iTextSharp.text.Image.GetInstance("01.jpg");
                document.Add(jpeg);
                //向PDF添加图片01.jpg
                document.Close();
            }

        }

    }

  • 相关阅读:
    WordCount C语言实现求文本的字符数,单词数,行数
    iOS 数据持久化
    Apple store加急审核
    iOSTableViewCell不等高的几种方法
    Xcode 插件(时间就是生命)
    iOS UI组件汇总
    iOS之获取经纬度并通过反向地理编码获取详细地址
    iOS 开发常用宏
    iOS让你的app一直在后台活着(运行)
    OC动画——基础动画CABasicAnimation使用
  • 原文地址:https://www.cnblogs.com/qq4004229/p/2159659.html
Copyright © 2011-2022 走看看