Java libraries to read and write PDF files

This page lists links to and short summaries of Java software which accesses PDF files. PDF, the Portable Document Format was designed by Adobe. A PDF file format specification is freely available from Adobe's website.

PDF has been changed over time, it's an extensible format and new features have been added. Among those feature are new compression filters, and implementations of some of those fall under patents in some countries. Free, open encoders and decoders which cover all valid PDFs are therefore not possible. For some compression types (like JBIG-2) I'm not even aware of a proprietary Java implementation. If you want to use a Java PDF decoder, try out a wide variety of PDF files to see if it suits your needs. Should you be in the position of controlling the complete workflow including PDF file generation this will probably not be an issue. Using a well-defined subset of PDF (like PDF/A) may be an option to avoid compatibility problems.

Library / packageLicenseDescription
Adobe Acrobat Reader for JavaFreewareRead and display PDF documents. A viewer application and a JavaBean are available. Works with Java 1.1.8+.
Big Faceless PDF libraryCommercialWrite PDF documents, with support for various advanced features.
ceTe SoftwareCommercialDynamicPDF Generator to write, DynamicPDF Merger to read and write PDF files.
Crionics jPDFCommercialManipulation of PDF files, especially suited for the server side. Features include PDF generation from templates, splitting, merging, parsing and encryption. Written in pure Java (requires Java 1.3 or higher).
ElegantJ PDF libraryCommercialJava library to create reports from arbitrary data sources as PDF.
Etymon PJGPL / CommercialRead and write PDF documents. There are two versions, classic and professional. Classic comes under the GPL and requires Java 1.1. Professional is commercial and requires Java 1.4.
FOPApache LicenseWrite PDF documents, render them from XML/XSL sources.
gnujpdfLGPLWrite PDF documents. An extension of the retepPDF project.
iTextLGPLWrite PDF documents. Requires Java 1.2. There's a book iText in Action by the library's author, Bruno Lowagie.
PDFGoCommercialRead PDF documents. Viewer (standalone application) and Java Bean available.
jPDFPrintCommercial (trial version available)Library to read and print PDF documents.
jPDFProcessCommercial (trial version available)Library to read, manipulate and save PDF documents. Manipulation operations include splitting, drawing, printing, encrypting and exporting as images.
jPDFViewerCommercial (trial version available)Java Bean to display PDF documents.
jPDFWriterCommercial (trial version available)Pure Java library to write PDF files. Library can be used like a Java printer job. Thus, existing Java code for printing can be reused to create PDF files.
JPedalGPL or site license or fixed feeRead PDF documents. This library can both extract content from PDFs and rasterize them.
JustFormsPDFCommercial (trial version available)Pure Java library for filling and editing PDF documents with forms. Requires Java 1.2+.
MultivalentSpecial licenseReads PDF and other document formats. Includes a browser to view all supported files. Provides various tools to manipulate PDF files: compress, uncompress, split, merge, encrypt, decrypt, info, validate, extract text, and full-text search (with Lucene). Source code available.
PDF stream writerFreewareJava library to convert XML to PDF files.
PDFBoxBSDLibrary to access PDF files. A utility to convert to text is included.
PDFlibCommercialRead and write PDF documents. This is a C library which has Java JNI bindings.
PDFTextStreamCommercialRead PDF documents. This library can extract text and metadata from PDF files. It supports PDF up to version 1.6 and comes with support for Lucene.
retepPDFGPLWrite PDF documents.
Saffron Document ServerCommercialReads PostScript (.ps) documents and generates PDF, HTML, RTF, TIFF, and other formats. Configured as a server for concurrent document rendering.
SmartJPrintGPL-likePure Java library to write PDF files. Generates PDF files from Swing GUI components, provides preview functionality.
SnowboundCommercialRead and write PDF files.
XMLMillCommercial, trial version availableCreate PDF documents from XML/XSL.

The Open Directory Project has its own category for Java libraries to read and write PDF files.

You want me to update an entry on this page, or a add a new one? Please read these remarks first!

License column

This column either contains the name of the license used, or the term commercial. In this list, commercial means the same as non-free, contrary to what the Free Software Movement suggests.  

`embed_txtfiles` 是一个自定义 CMake 函数,用于将多个文本文件嵌入到可执行文件中,以便在运行时读取这些文件内容。下面是一个示例函数的实现: ```cmake function(embed_txtfiles target_name) set(output_file "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_embedded_files.c") set(files_var_name "${target_name}_EMBEDDED_FILES") set(var_name "${target_name}_EMBEDDED_FILES_DATA") # Collect the file contents and embed them as char arrays set(srcs "") set(${var_name} "") foreach(file ${ARGN}) file(READ ${file} contents) string(REPLACE "\"" "\\\"" contents "${contents}") string(REPLACE "\n" "\\n\"\n\"" contents "${contents}") list(APPEND srcs "${CMAKE_CURRENT_BINARY_DIR}/temp/${file}.c") set(${var_name} "${${var_name}}static const char ${file}_data[] = \"${contents}\";\n") set(${var_name} "${${var_name}}static const size_t ${file}_size = ${CMAKE_CURRENT_BINARY_DIR}/temp/${file}_size;\n") endforeach() # Generate the C code that will be compiled into the executable file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/temp") file(WRITE ${output_file} "${${var_name}}\n") foreach(file ${ARGN}) file(SIZE ${file} size) set(size_var "${CMAKE_CURRENT_BINARY_DIR}/temp/${file}_size") file(WRITE ${size_var} "${size}") file(APPEND ${output_file} "extern const char ${file}_data[];\n") file(APPEND ${output_file} "extern const size_t ${file}_size;\n") endforeach() file(APPEND ${output_file} "\nvoid ${target_name}_init() {\n") foreach(file ${ARGN}) file(APPEND ${output_file} " resource_manager_add_resource(\"${file}\", ${file}_data, ${file}_size);\n") endforeach() file(APPEND ${output_file} "}\n") # Compile the generated C code into a library that can be linked into the target add_library(${files_var_name} STATIC ${srcs}) target_compile_definitions(${files_var_name} PRIVATE ${var_name}=${var_name}) target_include_directories(${files_var_name} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/temp") # Add a custom command to generate the C code and compile it before building the target add_custom_command( OUTPUT ${srcs} COMMAND ${CMAKE_COMMAND} -E copy ${ARGN} "${CMAKE_CURRENT_BINARY_DIR}/temp" COMMAND ${CMAKE_COMMAND} -E touch ${output_file} DEPENDS ${ARGN} COMMENT "Embedding TXT files in ${target_name}" ) # Add the custom command as a dependency of the target add_dependencies(${target_name} ${files_var_name}) # Link the embedded files library into the target target_link_libraries(${target_name} ${files_var_name}) endfunction() ``` 使用此函数的示例: ```cmake add_executable(myapp main.c) embed_txtfiles(myapp data/file1.txt data/file2.txt) ``` 在这个示例中,`embed_txtfiles` 函数将 `data/file1.txt` 和 `data/file2.txt` 嵌入到 `myapp` 可执行文件中。在运行时,可以使用 `resource_manager_get_resource("data/file1.txt")` 和 `resource_manager_get_resource("data/file2.txt")` 来获取这两个文件的内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值