Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
rakunavi
User
Posts: 2205
Joined: Sat Sep 11, 2021 5:04 am

Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

Post by rakunavi »

Hello all,

I would like to report a limitation in the macro parsing engine used in dialog text fields. I confirmed this behavior in the "Bookmark Every N-th Page" dialog, but it likely affects all dialogs that rely on the same macro system.

Problem:
It is currently impossible to end a text string with a percent sign (%) that immediately follows a macro value.

Steps to reproduce:
  1. Open the "Bookmark Every N-th Page" dialog.
  2. Enter %[page]% in the Bookmark Title Template field where macros are supported.
  3. The trailing % is ignored by the parser and does not appear in the bookmark output.
Attempted workarounds (all failed):
I tried several possible escape methods, but none allowed the percent sign to appear:

  • %[page]\% (backslash does not escape it)
  • %[page]`% (backquote does not escape it)
  • %[page]%% (outputs "5%%" instead of "5%", making it impossible to produce a single percent sign)
  • %[page]​% (even inserting a Zero‑Width Space U+200B between ] and % does not prevent the parser from swallowing the percent sign)
Additional observation:
This issue occurs only when the percent sign is the final character after a macro.
If any additional character is appended (e.g., "%[page]%X" or "%[page]% "), the percent sign appears correctly.
This strongly suggests that the parser incorrectly attempts to treat % as the beginning of another macro and fails to fall back to literal output when % is the final character.

Expected behavior:
After completing a macro such as %[page], the parser should treat subsequent characters literally, including a percent sign. This is a natural use case when users want to display values like "5%".

Hoping that the above information will be of some help to you.
Thank you for your hard work on this great software.

Best regards,
rakunavi

- PDF-XChange Editor PRO Version: 11.0.1
- OS Version: Windows 11 Pro / Home 25H2 Build 26200.8655
- PC Model: GMKtec Nucbox M7 Pro with HUION Kamvas Pro 19 / Lenovo IdeaPad C340-15IWL
Top needs for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FullScrnMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect