Golang PDF library for creating and processing PDF files (pure go)
This version contains new features, improvements and fixes.
CropBox
.This version contains major new features and improvements.
Examples for this new feature can be found at: https://github.com/unidoc/unipdf-examples/tree/master/redact
We have been working on this feature for a while and implemented without without making big changes to our existing document creation engine. We are very happy with the result. Check out examples for this for RTL in Arabic text: https://github.com/unidoc/unipdf-examples/tree/master/arabic-text
As a part of our efforts to improve reporting cababilities in the creator package, we have now revamped our Line component. The improvements include
Examples for the line component have been added here: https://github.com/unidoc/unipdf-examples/blob/master/drawing/pdf_draw_lines.go and can generate output such as: https://github.com/unidoc/unipdf-examples/blob/master/drawing/unipdf-draw-lines.pdf
This version contains fixes and improvements.
LTV signatures. Add option to ignore CRL and OCSP in DSS when client is nil. Example: https://github.com/unidoc/unipdf-examples/pull/188
Add support for full context width creator images.
Added img.SetFitMode(creator.FitModeFillWidth)
to expand to available width.
Fix nil copy object handling [UP-335].
Support for word wrapping in styled paragraphs [USD-191]. Avoids issues where latin text is wrapped anywhere.
This version is focused on improvements on the creator reporting capabilities, especially improvements for the division component and rounded corners support that facilitate creation of reports.
UniPDF version 3.34.0 contains new features and multiple bug fixes. Notably, we have added a support for native PDF charts via our newly released UniChart library that is based on the powerful https://github.com/wcharczuk/go-chart library. In addition, PDF/A-2 validation and optimization has been completed.
NOTE: Ticket numbers are included for reference.
UniPDF version 3.33.0 contains new features and multiple bug fixes. Notably, PDF/A-1A validation and generation has been completed and font extraction has been added.
NOTE: Ticket numbers are included for reference.
To try this out can use our examples for standard conversion and generation in https://github.com/unidoc/unipdf-examples/tree/master/pdfa and using the pdfa.NewProfile1A(nil)
profile.
The extractor has a new function
// ExtractFonts returns all font information from the page extractor, including// font name, font type, the raw data of the embedded font file (if embedded), font descriptor and more.
//
// The argument `previousPageFonts` is used when trying to build a complete font catalog for multiple pages or the entire document.
// The entries from `previousPageFonts` are added to the returned result unless already included in the page, i.e. no duplicate entries.
//
// NOTE: If previousPageFonts is nil, all fonts from the page will be returned. Use it when building up a full list of fonts for a document or page range.
func (e *Extractor) ExtractFonts(previousPageFonts *PageFonts) (*PageFonts, error) {
New Example: https://github.com/unidoc/unipdf-examples/blob/master/extract/pdf_extract_fonts.go
Adds to creator's Table type:
// EnablePageWrap controls whether the table is wrapped across pages.
// If disabled, the table is moved in its entirety on a new page, if it
// does not fit in the available height. By default, page wrapping is enabled.
// If the height of the table is larger than an entire page, wrapping is
// enabled automatically in order to avoid unwanted behavior.
func (table *Table) EnablePageWrap(enable bool) {
Outline destinations appear to be null for some types of PDFs [UP-323 ] Fixes problem reported in https://github.com/unidoc/unipdf/issues/482
Text extraction disorder occurs on this type of pdf [UP-322] Bug fix for certain case with particular CMap bfrange values.
Text extraction problem with mixed garbles/non-garbled text [UP-308 ] Bug fix for font cache name where multiple fonts could have same key, causing incorrect text mappings.
Problem with extracting images from CCITTDecode filter for a user provided file Bug fix for particular issue in CCITT encoding related to EOL handling. [UP-268]
UniPDF version 3.32.0 contains new features and multiple bug fixes. Notably new powerful support for DocMDP restrictions and validation has been added that allows controlled document permissions for digital signatures. In addition, we optimized our CCITTFaxdecode filter for better performance and made multiple other improvements. See more below.
NOTE: Ticket numbers are included for reference.
Improved support for digital signatures and setting and validating DocMDP permissions has been implemented. As part of this we added flexible support for accessing older revisions of documents. The following functions are now available (in core
package).
// GetRevisionNumber returns the current version of the Pdf document.
func (parser *PdfParser) GetRevisionNumber() int
// GetRevision returns PdfParser for the specific version of the Pdf document.
func (parser *PdfParser) GetRevision(revisionNumber int) (*PdfParser, error)
// GetUpdatedObjects returns pdf objects which were updated from the specific version (from prevParser).
func (parser *PdfParser) GetUpdatedObjects(prevParser *PdfParser) (map[int64]PdfObject, error)
New package model/mdp
is used for Modify Detection Prevention (MDP) such as controlling what changes are allowed in document revisions of a PDF document.
Ability to set and control DocMDP permissions on digital signatures [UP-14]
New examples added for this can be found in: https://github.com/unidoc/unipdf-examples/pull/168/files which includes:
Example signatures/pdf_sign_docmdp.go
shows how to sign a PDF document with defined DocMDP restrictions.
Example signatures/pdf_sign_docmdp_valid_changes.go
shows how to sign a PDF document with specified DocMDP restrictions and add some valid changes that pass validation.
Example signatures/pdf_sign_docmdp_invalid_changes.go
shows how to sign a PDF document with the DocMDP restriction and add some invalid changes that fail validation.
Example signatures/pdf_sign_get_revision.go
shows how to retrieve the specific or previous revision of a PDF document
Improvements have also been made in the creator
package for creating PDF documents.
New function in the creator package:
// Flip flips the active page on the specified axes.
// If `flipH` is true, the page is flipped horizontally. Similarly, if `flipV`
// is true, the page is flipped vertically. If both are true, the page is
// flipped both horizontally and vertically.
// NOTE: the flip transformations are applied when the creator is finalized,
// which is at write time in most cases.
func (c *Creator) Flip(flipH, flipV bool) error {
creator
: Improve border component [UP-301]
Fixed a bug with border calculations and added more testcases to ensure correct behavior.Following user feedback we reviewed margin handling in a few components and addressed a few problems.
Bassed on user documents we investigated some problems related to font encodings and cmaps affecting both text extraction and text rendering. The following improvements were made based on this:
Text extraction CID Font single-byte mapping. Fixes text decoding bug. [UP-287]
Text extraction problem addressed: ExtractText() returning garbled text [UP-303]. Added special cases for prioritization of text encoders to get better outputs for simple fonts.
Rendering problem: Output characters showing missing glyph instead of characters [UP-302]. Improved cmap handling in font glyph rendering package in github.com/unidoc/freetype which was forked from github.com/golang/freetype and improved for PDF rendering needs (mainly cmaps).
Additional fixes were made:
CCITT decoding support has been improved and optimized fixing [UP-131] Performance improvement - CCITTFax Decoder input and output should use bitwise.Reader and bitwise.Writer
model/pdfa: content stream optimizer fix. [UP-304]. Fixed a problem causing PDF/A optimization to miss colorspace optimization when no images were in the file.
UniPDF version 3.31.0 contains new features and multiple bug fixes. Major changes have been done related to experimental PDF/A support (which is still in beta) and the quality of verifiers and standardizers improved significantly. The list of changes is as follows.
Support for advanced XMP Metadata has been added. (examples to be added soon).
[UP-281] Improvements in PDF/A implementation prototype.
NOTE: Experimental PDF/A Profile1Options
no longer contains UUIDGenerator
field.
[UP-284] PdfAppender.Write() overrides PdfInfo
[UP-283] Margins aren't accounted for when drawing (creator)
[UP-280] Unable to extract specific text - missing text (extractor package)
[UP-272] "Invalid operand" being thrown when flattening fields with pdfreader
[UP-214] Render Bug: Text jumbled on page
[UP-202] USD-81 UniPDF render bug: poorly rendered text
UniPDF version 3.30.0 contains new features and multiple bug fixes. The list of changes is as follows.
UP-266 ExtractPageText is throwing an error: range check
UP-260 Image extraction hangs and memory keeps increasing
UP-264 Loaded fonts cause panics for concurrent map read and writes
UP-271 Update pkcs7 package to 0.1.0 (contains multiple fixes for digital signatures)
UP-270 Implement QA and testing process for PDF/A validation
UP-262 PDF Page Rotation hierarchy handling (fixes bugs when Rotate is specified on parent Pages element)
UniPDF version 3.29.0 contains new features and multiple bug fixes. Notably, PDF/A verification for fonts has been implemented. In addition, digital signing of encrypted PDF files is now supported.
The list of changes is as follows.
UP-259 ERROR: UniDoc pdfReader failed to ExtractPageText: pageNum=1 err=range check error
UP-256 invalid Page Rotate object
UP-255 Another instance of Split operation failed on v3.28.0
UP-254 Unexpected behaviour when the contents of the a cell that has a rowspan > 1 exceeds the height of the rest of the table.
UP-242 Signing invalidates document
UP-240 Optimizer issue: Failed creating multi encoder: invalid filter in multi filter array
UP-142 Rendering issue where image content is blacked out
UP-141 Path drawing looks different than in Adobe
UP-239 As a user I want to encrypt pdfs and allow signing encrypted pdfs so only intended users can view and sign them
UP-263 Implement PDF/A font verifiers
UP-241 creator - Add example for table rowspan
signatures/pdf_sign_and_encrypt_pdf.go Showcases how to encrypt and apply a digital signature to an encrypted file.
signatures/pdf_sign_twice_visible_annotation.go Example of multiple signing with visible annotations - digital signatures
text/pdf_search_replace_advanced.go More advanced example of search and replace with UniPDF.