Stirling-Tools / Stirling-PDF

#1 Locally hosted web application that allows you to perform various operations on PDF files
MIT License
42.3k stars 3.36k forks source link

[enhancement ]: Stamp feature to support custom fonts #1458

Open DO10-01 opened 3 months ago

DO10-01 commented 3 months ago

The Problem

Description:

The stamp feature in Stirling PDF introduces incorrect characters when stamping a specific string. The expected behavior is to stamp the string "Reproduktion eines digitalisierten Originals. Die Reproduktion stimmt mit dem Original überein." on each page. However, the actual result is "Reproduktion eines digitalisierten Originals? Die Reproduktion stimmt mit dem Original überein?". The question mark replaces the expected period.

Steps to Reproduce:

Open Stirling PDF (either Docker container or Windows executable) Navigate to the "Stamp" tool Enter the following text in the stamp field: "Reproduktion eines digitalisierten Originals. Die Reproduktion stimmt mit dem Original überein." Select the desired pages to stamp Apply the stamp

Expected Behavior:

The specified string should be stamped on each selected page without any character alterations.

Actual Behavior:

The stamped string includes an incorrect question mark instead of a period after "Originals".

Version of Stirling-PDF

0.26.0

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

http://192.168.178.155:7890/stamp

Docker Configuration

No response

Relevant Log Output

No response

Additional Information

The issue is observed in both the Docker container and the Windows executable versions of Stirling PDF. Please let me know if you require any further information or clarification regarding this bug report.

I've searched for solutions in the web before posting, but nothing found.

Browsers Affected

Chrome, Microsoft Edge, Other

No Duplicate of the Issue

Gokulviper commented 2 months ago

@Frooodle I have analyzed this issue and also debugged it. The code PDFont font = new PDType1Font(Standard14Fonts.FontName.HELVETICA); does not support special characters like dot (.) and comma (,). Instead of using this, I have used the DejaVuSans font to resolve the issue. Shall we proceed with these changes

Frooodle commented 2 months ago

How are you using DejaVuSans font? I believe it is actually using NotoSans-Regular.ttf correct?

https://github.com/Stirling-Tools/Stirling-PDF/blob/9e84836cfe96eb70eb07081bec014c0ab8fd0088/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java#L161

I suggest we add a additional alphabet for non basic fonts as an option

Gokulviper commented 2 months ago

@Frooodle I have added DejaVu.ttf to the resource folder. I also tried using NotoSans-Regular.ttf alone, but faced the same issue: it is not supported. However, using the DejaVu font, all characters are supported.