Add watermark to PDF files using iText library

Article directory iText library introduction required dependencies Watermark style encapsulation Package tool class Content Notes iText library introduction iText is a popular Java PDF library that can be used to create, read, modify, and extract PDF content. iText provides a number of APIs, including the ability to add text watermarks. Note: Create a Springboot to […]

Export Excel to pdf using iText

1. iText7 version <!– https://mvnrepository.com/artifact/com.itextpdf/itext7-core –> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext7-core</artifactId> <version>7.0.3</version> <type>pom</type> </dependency> @Slf4j public class ExcelToPdfConverter {<!– –> public static void converter(SXSSFWorkbook workbook, FileOutputStream fos) {<!– –> try {<!– –> // Get the first worksheet Sheet sheet = workbook.getSheetAt(0); //Create PDF document object int colWidth = getColWidth(sheet); PageSize pageSize; if (colWidth <= 21000){<!– –> pageSize […]

Java uses itext7 to support rich text generation of PDF

1. Rendering: (Some details and layout still need to be adjusted) Technical points: elementUI + WangEditor + SpringBoot + IText7 + 2. pom: <!– pdf:start –> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <itext.version>7.1.11</itext.version> </properties> <dependencies> <!– itext7 –> <dependency> <groupId>com.itextpdf</groupId> <artifactId>kernel</artifactId> <version>${itext.version}</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>io</artifactId> <version>${itext.version}</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>layout</artifactId> <version>${itext.version}</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>forms</artifactId> <version>${itext.version}</version> </dependency> […]

SpringBoot Thymeleaf iText7 generates PDF (2023/08/29)

SpringBoot Thymeleaf iText7 generates PDF (2023/08/29) Article directory SpringBoot Thymeleaf iText7 generates PDF (2023/08/29) 1 Introduction 2. Technical ideas 3. Implementation process 4. Test 1. Preface Recently, I encountered the need to generate complex PDFs in real time in a project. After some research and testing, I finally chose to use Thymeleaf and iText7 to […]

Use iTextSharp to process PDFs

Create PDF files using System; using System.Collections.Generic; using System.Text; using iTextsharp.text; using iTextsharp.text.pdf; using System.IO; using System.Windows.Forms; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { iTextsharp.text.Document pdf doc new Document(); Pdfwriter pdf write Pdfwriter.GetInstance(pdf doc,new Filestream(@”I:\chap1.pdf”,FileMode.Create)); pdfdoc.Open() pdf doc.Add(new Paragraph (“new pdf!”)); pdf doc.close(); MessageBox.Show (“OK!”,Environment.UserName); Console.Read(); } } } Use iTextSharp […]

Spring boot+itextpdf generates a simple application of pdf

1.Introduce maveny dependencies <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> 2. Implement the code // pdf file saving path String fileName = voSubLedger.getTargetPath() + “/” + beginDate + “-” + endDate + categoryName + “detailed account” + “.pdf”; //Create a document instance, set the specification to A4 paper, and set the margins […]

Optimize the solution of using itext to merge multiple pdfs, and solve the problem of PDF header signature not found when using itext to merge pdfs.

Table of Contents 1. Original link: 2. Code analysis 3. Solve problems 4. Use extensions 1. Original link: (Solved) Error when merging PDF using Itext: com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found_Xiaoqing_007’s blog-CSDN blog 2. Code analysis This is my last code about itext, which has solved the problem of PDF header signature not found. After […]

[Java] Generate barcodes in batches-itextpdf

Generate barcodes in batches Controller @ApiOperation(“Product list generates product barcodes in batches”) @PostMapping(“/batchGenerateProdBarCode”) public void batchGenerateProdBarCode(@RequestBody ProductListCondition productListCondition,HttpServletResponse response){<!– –> importExportService.batchGenerateProdBarCode(response, productListCondition); } service /** * Product list generates product barcodes in batches * @param productListCondition * @return */ public void batchGenerateProdBarCode(HttpServletResponse response,ProductListCondition productListCondition){<!– –> List<MProductEx> productExList = mProductListDao.selectmproduct( productListCondition.getProdCdDis(),productListCondition.getBrand()); try {<!– –> int dataCount […]