itext

Java使用lowagie根据模版动态生成PDF(无需额外设置系统字体) Java动态生成pdf文件 阅读详情
/**
 *
 */
package com.hsbc.gltc.itext.test;

import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;






import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfAcroForm;
import com.lowagie.text.pdf.PdfAnnotation;
import com.lowagie.text.pdf.PdfAppearance;
import com.lowagie.text.pdf.PdfBorderDictionary;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfFormField;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.RadioCheckField;
import com.lowagie.text.pdf.TextField;

import junit.framework.TestCase;

/**
 * @author 43454131
 *
 */
public class ITextTestCase_CNS_KYC_en extends TestCase {
    
       public static final String[] page1RadioCheckBoxes = { "AT_1_A", "AT_1_B", "AT_1_C", "AT_1_D", "AT_1_E","AT_1_F","AT_1_G"};
    
     public static final String[] page1Radios_Y = { "AT_2_A", "AT_3_A", "AT_4_A", "AT_5_A", "AT_6_A","AT_7_A","AT_8_A","AT_9_A"};
     public static final String[] page1Radios_N = { "AT_2_B", "AT_3_B", "AT_4_B", "AT_5_B", "AT_6_B","AT_7_B","AT_8_B","AT_9_B"};
    
     public static final String[] page1InputTexts = { "AN_2_A", "AN_3_A", "AN_4_A", "AN_5_A", "AN_6_A","AN_7_A","AN_9_A"};
    
     public static final String[] page2Radios_Y = { "6_Y", "7_Y", "8A_Y", "8B_Y", "9_Y"};
     public static final String[] page2Radios_N = { "6_N", "7_N", "8A_N", "8B_N", "9_N"};

    
    
    /** The original PDF file. */
    public static final String DATASHEET
        //= "src/test/resources/datasheet.pdf";
   // = "src/test/resources/CNS2.0_EN_v0.2.pdf";
    = "src/test/resources/CNS2.0_CN_change.PDF";
    /** The resulting PDF file. */
    public static final String RESULT
        = "c:/helloworld.pdf";
    public static final String RESULT2
    = "c:/helloworld2.pdf";
    public static final String IMAGE_RES
    = "src/test/resources/hsbclogo.gif";
    /* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
    }

    public void testGenPDFByForm() throws Exception{
        
        this.generatePDFByForm("c:/CNS2.0 CN_change1.PDF", "c:/CNS2.0 CN_change2.PDF", "attdRisk", this.getStr());
        System.out.println("done"+getStr());
    }
    
    public void testGenPDFByDoc() throws Exception{

        
        this.generatePDFByDoc(getStr());
        System.out.println("done"+getStr());
    }
    
    public void testCreatePDFWithForm() throws Exception{
        String path1 = "c:/ctpdf1.pdf";
        String path2 = "c:/ctpdf2.pdf";
        String path3 = "c:/ctpdf3.pdf";
//        this.createPdf(path1, false, false, this.getStr());
       // this.createPdf(null, path2, true, false, this.getStr());
//        this.createPdf(path3, false, true, this.getStr());
       // this.generatePDFByForm(path2, RESULT, "description", this.getStr()+"\u66f4\u6539\u7e73\u4ed8\u4fdd\u8cbb\u6307\u793a");
    }
    
    private BaseFont getBaseFont() throws DocumentException, IOException{
//        BaseFont font = BaseFont.createFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED);
        BaseFont font = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.MACROMAN, BaseFont.NOT_EMBEDDED);
        return font;
    }
    
    private BaseFont getBaseFontChinese() throws DocumentException, IOException{
        BaseFont font = BaseFont.createFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED);
//        BaseFont font = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.MACROMAN, BaseFont.NOT_EMBEDDED);
        return font;
    }
    
    
    public void generatePDFByForm(String filepath, String result,String fieldname, String str) throws Exception{
        PdfReader reader = new PdfReader(filepath);

        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(result));
        stamper.getWriter().getAcroForm().setNeedAppearances(true);
        AcroFields form = stamper.getAcroFields();
        BaseFont font = this.getBaseFont();
        
        form.setFieldProperty(fieldname,"textfont",font,null);
        
        form.setField(fieldname, str );
        stamper.setFormFlattening(true);
        
//        PdfContentByte cb = stamper.getUnderContent(1);
//        Image img;
//        java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage(IMAGE_RES);
//        img = Image.getInstance(awtImage, null);
//        cb.addImage(img, 200, 10, 10, 10, 10, 10);
        
        stamper.close();
    }
    
    public void generatePDFByDoc(String str)throws Exception{
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(RESULT2));
        // step 3
        document.open();
        // step 4
        BaseFont bf;
        
        bf = this.getBaseFont();
        Font font = new Font(bf, 12);
        document.add(new Paragraph(str, font));
        // step 5
        document.close();

    }
    
    public String getStr(){
        final ApplicationContext ctx = new ClassPathXmlApplicationContext(
                new String[] {"/gltc/helloworld/intg/itext/tmpl/config.xml",});

        String testMessage = (String) ctx.getBean("riskStr");
        
        return testMessage + "\u53d6\u6d88\u6307\u793a";
    }
    
    public void createPdf(String input,String filename, boolean appearances, boolean font,
            String str) throws IOException, DocumentException {
        // step 1
        Document document = new Document();
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream(filename));
        // step 3
        document.open();
        PdfReader reader = null;
/*********************Page 1 START*****************************************/    
        if(StringUtils.isNotBlank(input)){
            reader = new PdfReader(new FileInputStream (new File (input)));
            
            //add template
            PdfContentByte pdfContentByte = writer.getDirectContent();                
            PdfImportedPage page = writer.getImportedPage(reader, 1);
            pdfContentByte.addTemplate(page,0,0);
        }

        

//            cb.moveTo(0, 0);
//            rect = new Rectangle(49, 300, 59, 310);
//        drawCheckbox(writer, rect, "ckaCheckBox","Off");
        writer.getAcroForm().setNeedAppearances(appearances);
        
        PdfContentByte cb = writer.getDirectContent();
        cb.moveTo(0, 0);
        
        // Add the check boxes
        PdfContentByte canvas = writer.getDirectContent();
        PdfFormField field;
        PdfFormField field2;

        PdfAppearance[] onOff = new PdfAppearance[2];
        onOff[0] = canvas.createAppearance(20, 20);
        onOff[0].rectangle(1, 1, 18, 18);
        onOff[0].stroke();
        onOff[1] = canvas.createAppearance(20, 20);
        onOff[1].setRGBColorFill(255, 128, 128);
        onOff[1].rectangle(1, 1, 18, 18);
        onOff[1].fillStroke();
        onOff[1].moveTo(1, 1);
        onOff[1].lineTo(19, 19);
        onOff[1].moveTo(1, 19);
        onOff[1].lineTo(19, 1);
        onOff[1].stroke();
        RadioCheckField checkbox;
        RadioCheckField checkbox2;
        Rectangle[] rectArrays = new Rectangle[12];
        rectArrays[0] = new Rectangle(460, 482, 490, 452);
        rectArrays[1] = new Rectangle(460, 445, 490, 415);
        rectArrays[2] = new Rectangle(460, 412, 490, 382);
        rectArrays[3] = new Rectangle(460, 372, 490, 342);
        rectArrays[4] = new Rectangle(460, 312, 490, 282);
        rectArrays[5] = new Rectangle(460, 265, 490, 237);
        rectArrays[6] = new Rectangle(460, 237, 490, 211);
        rectArrays[7] = new Rectangle(460, 211, 490, 183);
        rectArrays[8] = new Rectangle(460, 183, 490, 157);
        rectArrays[9] = new Rectangle(460, 157, 490, 130);
        rectArrays[10] = new Rectangle(460, 130, 490, 102);
        rectArrays[11] = new Rectangle(460, 102, 490, 74);
        
        Rectangle[] rectArrays2 = new Rectangle[12];
        rectArrays2[0] = new Rectangle(510, 482, 540, 452);
        rectArrays2[1] = new Rectangle(510, 445, 540, 415);
        rectArrays2[2] = new Rectangle(510, 412, 540, 382);
        rectArrays2[3] = new Rectangle(510, 372, 540, 342);
        rectArrays2[4] = new Rectangle(510, 312, 540, 282);
        rectArrays2[5] = new Rectangle(510, 265, 540, 237);
        rectArrays2[6] = new Rectangle(510, 237, 540, 211);
        rectArrays2[7] = new Rectangle(510, 211, 540, 183);
        rectArrays2[8] = new Rectangle(510, 183, 540, 157);
        rectArrays2[9] = new Rectangle(510, 157, 540, 130);
        rectArrays2[10] = new Rectangle(510, 130, 540, 102);
        rectArrays2[11] = new Rectangle(510, 102, 540, 74);
        
        for (int i = 0; i < page1Radios_Y.length; i++) {
            checkbox = new RadioCheckField(writer, rectArrays[i], page1Radios_Y[i], "on");
            checkbox.setCheckType(RadioCheckField.TYPE_CHECK);
            field = checkbox.getCheckField();
            checkbox.setBorderColor(Color.white);
//            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff[0]);
            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onOff[1]);
            writer.addAnnotation(field);
        }
        
        for (int i = 0; i < page1Radios_N.length; i++) {
            checkbox2 = new RadioCheckField(writer, rectArrays2[i], page1Radios_N[i], "on");
            checkbox2.setCheckType(RadioCheckField.TYPE_CHECK);
            field2 = checkbox2.getCheckField();
            checkbox2.setBorderColor(Color.WHITE);
//            field2.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff[0]);
            field2.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onOff[1]);
            writer.addAnnotation(field2);
        }
        
        //for textFields
//        Rectangle[] page1TextFieldRectArrays = new Rectangle[12];
//        page1TextFieldRectArrays[0] = new Rectangle(510, 482, 540, 452);
//        page1TextFieldRectArrays[1] = new Rectangle(510, 445, 540, 415);
//        page1TextFieldRectArrays[2] = new Rectangle(510, 412, 540, 382);
//        page1TextFieldRectArrays[3] = new Rectangle(510, 372, 540, 342);
//        page1TextFieldRectArrays[4] = new Rectangle(510, 312, 540, 282);
//        page1TextFieldRectArrays[5] = new Rectangle(510, 265, 540, 237);
//        page1TextFieldRectArrays[6] = new Rectangle(510, 237, 540, 211);
//        page1TextFieldRectArrays[7] = new Rectangle(510, 211, 540, 183);
//        page1TextFieldRectArrays[8] = new Rectangle(510, 183, 540, 157);
//        page1TextFieldRectArrays[9] = new Rectangle(510, 157, 540, 130);
//        page1TextFieldRectArrays[10] = new Rectangle(510, 130, 540, 102);
//        page1TextFieldRectArrays[11] = new Rectangle(510, 102, 540, 74);
//        
//        for(int i = 0;i<page1InputTexts.length;i++){
//            TextField textField= new TextField(writer,page1TextFieldRectArrays[i], page1InputTexts[i]);
//            textField.setFontSize(9);
//            textField.setOptions(TextField.MULTILINE);
//            writer.addAnnotation(textField.getTextField());
//        }
        
/*********************Page 1 END*****************************************/        
        
        
/*********************Page 2 START*****************************************/    
        if (StringUtils.isNotBlank(input)) {
            document.newPage();
            writer.getDirectContent().addTemplate(
                    writer.getImportedPage(reader, 2), 0, 0);
            
        }
        PdfContentByte cb3 = writer.getDirectContent();

        cb3.moveTo(0, 0);
        
        // Add the check boxes
        PdfContentByte canvas3 = writer.getDirectContent();
        PdfFormField field3;
        PdfFormField field4;

        
        PdfAppearance[] onOff3 = new PdfAppearance[2];
        onOff3[0] = canvas3.createAppearance(20, 20);
        onOff3[0].rectangle(1, 1, 18, 18);
        onOff3[0].stroke();
        onOff3[1] = canvas3.createAppearance(20, 20);
        onOff3[1].setRGBColorFill(255, 128, 128);
        onOff3[1].rectangle(1, 1, 18, 18);
        onOff3[1].fillStroke();
        onOff3[1].moveTo(1, 1);
        onOff3[1].lineTo(19, 19);
        onOff3[1].moveTo(1, 19);
        onOff3[1].lineTo(19, 1);
        onOff3[1].stroke();
        RadioCheckField checkbox3;
        RadioCheckField checkbox4;
        Rectangle[] rectArrays3 = new Rectangle[5];
        rectArrays3[0] = new Rectangle(460, 626, 490, 596);
        rectArrays3[1] = new Rectangle(460, 526, 490, 496);
        rectArrays3[2] = new Rectangle(460, 446, 490, 416);
        rectArrays3[3] = new Rectangle(460, 405, 490, 375);
        rectArrays3[4] = new Rectangle(460, 326, 490, 296);
        
        Rectangle[] rectArrays4 = new Rectangle[5];
        rectArrays4[0] = new Rectangle(510, 626, 540, 596);
        rectArrays4[1] = new Rectangle(510, 526, 540, 496);
        rectArrays4[2] = new Rectangle(510, 446, 540, 416);
        rectArrays4[3] = new Rectangle(510, 405, 540, 375);
        rectArrays4[4] = new Rectangle(510, 326, 540, 296);
       
        for (int i = 0; i < page2Radios_Y.length; i++) {
            checkbox3 = new RadioCheckField(writer, rectArrays3[i], page2Radios_Y[i], "on");
            checkbox3.setCheckType(RadioCheckField.TYPE_CHECK);
            field3 = checkbox3.getCheckField();
            checkbox3.setBorderColor(Color.WHITE);
//            field3.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff3[0]);
            field3.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onOff3[1]);
            writer.addAnnotation(field3);
        }
        
        for (int i = 0; i < page2Radios_N.length; i++) {
            checkbox4 = new RadioCheckField(writer, rectArrays4[i], page2Radios_N[i], "on");
            checkbox4.setCheckType(RadioCheckField.TYPE_CHECK);
            field4 = checkbox4.getCheckField();
            checkbox4.setBorderColor(Color.WHITE);
//            field4.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff3[0]);
            field4.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onOff3[1]);
            writer.addAnnotation(field4);
        }
        
        
      //for textFields
//        Rectangle[] page2TextFieldRectArrays = new Rectangle[12];
//        page2TextFieldRectArrays[0] = new Rectangle(510, 482, 540, 452);
//        page2TextFieldRectArrays[1] = new Rectangle(510, 445, 540, 415);
//        page2TextFieldRectArrays[2] = new Rectangle(510, 412, 540, 382);
//        page2TextFieldRectArrays[3] = new Rectangle(510, 372, 540, 342);
//        page2TextFieldRectArrays[4] = new Rectangle(510, 312, 540, 282);
//        page2TextFieldRectArrays[5] = new Rectangle(510, 265, 540, 237);
//        page2TextFieldRectArrays[6] = new Rectangle(510, 237, 540, 211);
//        page2TextFieldRectArrays[7] = new Rectangle(510, 211, 540, 183);
//        page2TextFieldRectArrays[8] = new Rectangle(510, 183, 540, 157);
//        page2TextFieldRectArrays[9] = new Rectangle(510, 157, 540, 130);
//        page2TextFieldRectArrays[10] = new Rectangle(510, 130, 540, 102);
//        page2TextFieldRectArrays[11] = new Rectangle(510, 102, 540, 74);
//        
//        for(int i = 0;i<page1InputTexts.length;i++){
//            TextField textField= new TextField(writer,page2TextFieldRectArrays[i], page1InputTexts[i]);
//            textField.setFontSize(9);
//            textField.setOptions(TextField.MULTILINE);
//            writer.addAnnotation(textField.getTextField());
//        }
//        
//        writer.getAcroForm().setNeedAppearances(appearances);
        
/*********************Page 2 END*****************************************/    
        
        /*********************Page 3 START*****************************************/
        if (StringUtils.isNotBlank(input)) {
            document.newPage();
            writer.getDirectContent().addTemplate(
                    writer.getImportedPage(reader, 3), 0, 0);
            
        }
        
//        writer.getAcroForm().setNeedAppearances(appearances);
        
        /*********************Page 3 END*****************************************/    
        document.close();
    }
    
    public void testCreatePDFWithForm2() throws Exception{
        String pdfTempl = "C:/Users/43709342/Desktop/task/QAS FOLDERS/pdf/HistoryPrintPDF/originalPDF/KYC.pdf";
        String outPDF = "C:/Users/43709342/Desktop/task/QAS FOLDERS/pdf/HistoryPrintPDF/templatePDF/CNS8.0_EN.pdf";
      this.createPdf(pdfTempl, outPDF, true, true, this.getStr());
    }

    
}


用itext生成pdf报表上篇 ITEXT 生成PDF报表 这几天,项目中要生成报表,网上查了下,这个itext很简单,对数据字段少的表生成报表很好用。看了一天,自己做了个例子。 首先是下载它的jar包,我这用的是itext.2.1.7.jar,可以直接到我的优快云中下载,免费的。 package com.tang.base; import java.awt.Color; import java.io.FileOut 阅读详情

相关推荐

Itext生成pdf细节

1、pdf生成与显示 response.reset(); response.setContentType("application/pdf"); Document document = new Document(PageSize.A4); //设置表格的形式 String filePath=pageContext.getServletCont

心中无码 5357

总结之使用lowagie.text添加PDF水印

引入依赖 <!-- pdf水印 --> <dependency> <groupId>com.lowagie.text</groupId> <artifactId>com.springsource.com.lowagie.text</artifactId> <version>${com.lowagie.text.version}</version> </dependency

IManiy的博客 4102

itext添加水印

/** * 图片水印 * @param pdfBty * @param imagePath * @return * @throws Exception */ public byte[] imageWatermark(byte[] pdfBty, String imagePath) throws Exception { PdfReader reader=null; PdfS...

IT_探的博客 1926

利用java的iText操作PDF文件

使用背景:存在一个PDF模板,此模板预留很多信息进行填写,类似于表单。并非代码生成一个pdf模板。 java代码:                                           // 通过一个int型的type。在string数组里面找到相应的pdf名字                 String name = findNameByType(typ

Java、node 1019

itext 7使用笔记

itext 7使用笔记 一、前言 二、使用 1.pom.xml 2.pdf模板编辑 3.工具类

搬山境KL攻城狮的修炼手册 3832

构建PDF数字签名系统:ITEXT+keytool项目实践

本文还有配套的精品资源,点击获取 简介:PDF数字签名技术是利用公钥基础设施(PKI)来确保文档完整性和可信度的关键机制。本项目演示了如何使用Java的ITEXT库处理PDF文档,以及如何利用keytool生成数字证书来实现PDF的数字签名。项目涵盖从生成数字证书到在PDF中应用签名的全过程,包括对非对称加密、ITEXT库工具和keytool的使用说明。项目还包括代码实现的...

weixin_42596214的博客 1275

AcroFields的setFieldProperty方法是做什么的,如何使用

AcroFields的setFieldProperty方法是用来设置AcroField属性的。可以使用该方法来设置AcroField的颜色、可见性、是否可编辑等属性。 使用方法为:acroFields.setFieldProperty(fieldName, property, value, inst); fieldName: 需要设置属性的AcroField的名称 property: 需要设置...

weixin_35755562的博客 1522

CentOS 环境 sngrep 安装及使用

在呼叫中心类应用开发过程中,经常需要对 SIP 信令抓包,分析排查问题。通常抓包的工具非常多样,如 Wireshark、tcpdump、ngrep 等都是可选项,但是针对 SIP 信令的抓包,sngrep 则更为好用。因为 sngrep 不仅提供了图形界面,还会将一通会话的 SIP 信令关联汇总,非常直观执行以下命令下载 的相关依赖库 1.2 添加 sngrep 的源并导入 执行下面的命令新增一个源仓库配置文件 然后在该文件中写入以下配置内容 执行命令导入源仓库的公钥 1.3 安装 sngrep

谈谈1974 8145

字体程序

常用的adobe公司的字体程序和对应编码: 字体程序 编码 STSong-Light UniGB-UCS2-H MHei-Medium UniCNS-UCS2-H MSung-Light UniCNS-UCS2-H HeiseiKakuGo-W5 UniJIS-UCS2-H HeiseiMin-W3 UniJIS-UCS2-H HYGoThic-Medium U...

weixin_42475998的博客 842

【Allegro学习笔记】常规标贴封装创建-0402封装创建实例

摘要 本文主要介绍如何使用Allegro制作表面贴装封装。 所使用的软件 使用Allegro制作常规贴片封装主要使用的软件有Pad Designer和Allegro 1 0402类封装制作 1.1 0402类封装焊盘分析 0402封装尺寸图如图1...

Honglong 1万+

JavaSpringBoot + VUE 相关开发环境配置合集

1.Java环境-JDK安装 参照:Java基础1-环境篇:JDK安装与环境变量配置 Java基础1-环境篇:JDK安装与环境变量配置_第一段代码的博客-优快云博客_jdk 2.Web服务器-Tomcat安装 原创Java服务器Tomcat安装和配置 3.Maven(后面为了项目兼容性,使用了3.0.5版本) 原创Maven安装和配置(Maven3.0.5) 4.nginx 原创nginx轻量级Web服务器安装和配置 5 数据库mysql 原创数据库Mysql安装和配置 ...

第一段代码的博客 3163

为何选择iText?java PDF开源库选择与iText发展历史

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;转眼间,我写iText7系列已经有一年多了,还记得最开始的时候是因为兴趣才翻译iText,不过随着慢慢翻译文章才发现iText的强大之处,最近也是调研了整个java PDF开源库的生态圈,我给大家详细讲一下java PDF开源库的选择还有我选择iText的理由。 1. 源起PDF 1.1 PDF定义 &amp;nbsp;&amp;nbsp;&amp;nbsp;

CuteKe的专栏 3万+

Python爬虫反爬:突破Cloudflare 5秒盾(免费方案,小红书/知乎可用)

这套方案的核心优势是“真实模拟+免费无门槛”无需付费代理、无需复杂JS解密,仅用playwright模拟真实浏览器,即可突破Cloudflare 5秒盾;适配小红书、知乎、豆瓣等主流平台,修改配置即可复用;兼顾易用性和稳定性,新手也能快速上手,企业级场景可通过IP轮换、异步爬取进一步优化。“模拟人类行为到底”——Cloudflare的反爬本质是区分“机器”和“人类”,只要爬虫的浏览器指纹、行为特征与人类一致,就能稳定绕过限制。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2880

ITEXT

       最近在找资料写JAVA导PDF的东西,LEADER(我一直在想是叫LEADER还是应该叫SUPERVISOR?)让我用ITEXT,并把公司里有几个有用到导PDF的系统给我参考下.      可那几个系统实现的东西都很简单,我要导的PDF用那些方法不能实现.所以好多问题还得自己上网搜查,不过有关ITEXT的资料都是少的可怜,不过在我努力找资料以及不断的试验当中,大多数问题都解决了,

jeff1709的专栏 1420

BMS硬件设计要点:从STM32主控到BQ76920监控芯片的工程实践

电池管理系统(BMS)是锂电安全与寿命保障的核心,其硬件设计涉及微控制器选型、专用监控芯片接口、电源完整性、信号完整性及PCB布局等多维度协同。基于STM32与BQ76920的典型双层架构,需深入理解功能安全解耦原理——关键保护由ASIC硬件实现,算法决策交由MCU完成,契合ASIL-B等级要求。技术价值体现在毫秒级硬件保护响应、±10mV电压采样精度及抗EMI鲁棒性设计;广泛应用于电动工具、储能系统与轻型电动车等中高功率场景。本文聚焦BMS控制板硬件实现中的高频时钟EMC、I²C总线信号完整性、被动均衡可

weixin_30591519的博客 92

LVGL core group焦点分组管理(lv_group.c)

lv_group_t是用于焦点管理的,将需要获取焦点的对像加入到同一个分组内,再将其通过挂到指定的事件驱动中,就可以控制焦点了。而被加入的对象又可以通过焦点状态事件和事件来控制对象的焦点逻辑了。创建好的分组通过接口挂事件驱动中,这样就可以指定一个自定义的焦点分组了。;) {if(!} }友情提示:无论是接口还是都是单例的,即被设置后前一个被设置的值就失效了;此方案可以保证焦点的唯一 性,但也一定要记住要在适合的位置设置回来,以防丢失焦点。

Bigan(安)的博客 3907

iText 简介

iText 简介 iText 是业界使用最为广泛的创建 PDF 的框架,从 iText 5 升级到 iText 7 后,功能模块的划分更加清晰,两者在使用上,有较为明显的区别。 使用 Maven 管理工具引入两者的代码如下: <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext7-core</artifactId> <version>7.1.11</ve

集腋成裘 4776

秃鹰搜索优化算法(BES)详解:从自然捕食到全局优化

秃鹰搜索优化算法(Bald Eagle Search Optimization Algorithm,BES)是由马来西亚学者Alsattar等人于2020年提出的一种新型元启发式优化算法。该算法灵感来源于秃鹰在自然界中高超的捕食行为,特别是其独特的狩猎策略和卓越的视觉搜索能力,模拟了秃鹰捕食鲑鱼等猎物的完整过程。

qq_42212808的博客 1350

iText操作word

用Itext操作word需要导入三个jar包:iText-2.1.7.jar、iText-rtf-2.1.7.jar、iTextAsian.jar private void execute(){ document = new Document(PageSize.A4); try { RtfWriter2.getInstance(document, new FileOutpu...

hu_lin123的博客 2047

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

itext私钥签名

最近再研究ITEXT,走过好多坑。在这里备份一下,也让大家少走一些弯路。 使用私钥签章很简单,网上百度,一大把,不多说,直接上代码; 前提,你需要一个PKCS12,带签章PDF和需要盖章的图片,如果没有,使用私钥和证书也可以,看自己喜好,修改代码 ps:本人使用的是itext5.5.13。 public static final String KEYSTORE_SELF = "E:\\t...

a501934002的博客 1345

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

iText使用

iText简单使用

xiaohuozi_97的博客 4031

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

itext 7 使用总结

1、自定义一个ITEXT事件处理器,这个类需要实现IEvenHandler,在这个类里面写实现页眉页脚的逻辑;这里添加了华文琥珀和黑体两个字体,将字体拷贝的项目的资源目录下,不拷贝也行,定义的路径直接指向系统字体库。,不同版本差距很大,这里引入的是7.1.9,选择该版本进去查看。宋体细体,ITEXT本身有,可以直接使用。使用它就能输出中文。2、在创建PdfDocument对象后调用该事件处理类即可。实现需要分成两个步骤,

weixin_52517502的博客 4399

java通过itext生成PDF,设置单元格cell的最大高度 以及 itext7初尝

网上百度java生成pdf都是很老的代码,使用的是itext5,找遍了大江南北都找不到设置表格或单元格最大高度,或者绝对定位表格的实现,最后对table和cell的方法一个一个找,找到了满足要求的方法: cell.setMaxLines(int numberOfLines) 由于字体确定,每行字体的高度已确定,设定最大行数也就设定了最大高度,且避免了设置的高度不是每行高度的整数倍的麻烦,i

无人问津的博客 2万+

iText Silent printing

iText这个免费的东东还真是好用, 之前用它生成、合并PDF文档,完全没有问题。最近客户又有了新需求, 要求说在打开PDF的同时,弹出printer setup dialog . 以下是ITEXT网站里的sample. 在生成pdf的同时,可以加一句javascript到PDF里面去, 来打印这个PDF。Document document = new Document();   

lisa429的专栏 2241

使用itext踩过的坑

说明:很多时候我们会使用itext 来导出pdf。其实我们最关心的无非是两个问题。1.如何快速使用itext导出pdf。2.使用哪个版本以及能否支持中文。第一点我将在下一篇文章中写自己开发了一套报表打印后的收获,以及代码。这里主要说第二点。下面我先贴一段代码(这个是我从网上搜来的)。Document document = new Document(); File file = new File("...

VSILENCE的博客 8631
上一篇: 策略模式
下一篇: Iphone 开发环境
努力去分享的老程序猿
博客等级 码龄15年 5粉丝 49原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值