unidoc / unipdf-examples

Examples for creating and processing PDF files with UniPDF https://github.com/unidoc/unipdf
https://unidoc.io
272 stars 101 forks source link

[QUESTION] Replace text with same width as original #94

Closed gunnsth closed 2 years ago

gunnsth commented 4 years ago

Question received via email.

One more question about this example: https://github.com/unidoc/unipdf-examples/blob/development/text/pdf_search_replace_advanced.go

It is possible to generate replacement string which will have the same width like original?

For example, I have a MODEL.PDFFONT object and FONTSIZE and I need to generate a string with spaces (u0020)

Example data was provided.

gunnsth commented 2 years ago

It is possible, but takes some care, need to check exactly the length of the original and the replacement text and adjust some variable like spacing or to get it to the same spacing. Note that we have since added a redactor package that handles many of the complexities of text removal. https://github.com/unidoc/unipdf-examples/tree/master/redact