Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessible math showing as white text against the "DRAFT" watermark #188

Closed
ronaldtse opened this issue Aug 18, 2022 · 9 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ronaldtse
Copy link
Contributor

Example below:
Screen Shot 2022-08-18 at 10 54 07 AM

Is it possible to not show the accessible math as white text at all (e.g. 100% transparency of text)?

@ronaldtse ronaldtse added the bug Something isn't working label Aug 18, 2022
@Intelligent2013
Copy link
Contributor

In XSL-FO there isn't property to set text transparency. I'll investigate how to tweak it. At first glance there are two options (don't sure where they can be applited yet):

  • move text behind background image with watermark (change z-order)
  • set 'Text rendering mode' to 3 Tr (9.3.6 in PDF Spec):
    image

@ronaldtse
Copy link
Contributor Author

Looks like both are good options and probably should do both. And we should extend the previous blog post with this new technique too.

Intelligent2013 added a commit to metanorma/mn2pdf that referenced this issue Aug 18, 2022
@Intelligent2013
Copy link
Contributor

Intelligent2013 commented Aug 18, 2022

mn2pdf updated for 1st option (metanorma/mn2pdf@6b66616)

move text behind background image with watermark (change z-order)

image

Text is searchable - checked:
image

@Intelligent2013
Copy link
Contributor

Regarding 2nd option, the the FOP class fop-core\src\main\java\org\apache\fop\pdf\PDFTextUtil.java there are constants:

/** PDF text rendering mode: Fill text */
    public static final int TR_FILL = 0;
    /** PDF text rendering mode: Stroke text */
    public static final int TR_STROKE = 1;
    /** PDF text rendering mode: Fill, then stroke text */
    public static final int TR_FILL_STROKE = 2;
    /** PDF text rendering mode: Neither fill nor stroke text (invisible) */
    public static final int TR_INVISIBLE = 3;
    /** PDF text rendering mode: Fill text and add to path for clipping */
    public static final int TR_FILL_CLIP = 4;
    /** PDF text rendering mode: Stroke text and add to path for clipping */
    public static final int TR_STROKE_CLIP = 5;
    /** PDF text rendering mode: Fill, then stroke text and add to path for clipping */
    public static final int TR_FILL_STROKE_CLIP = 6;
    /** PDF text rendering mode: Add text to path for clipping */
    public static final int TR_CLIP = 7;

and the method setTextRenderingMode:

/**
     * Sets the text rendering mode.
     * @param mode the rendering mode (value 0 to 7, see PDF Spec, constants: TR_*)
     */
    public void setTextRenderingMode(int mode) {
        if (mode < 0 || mode > 7) {
            throw new IllegalArgumentException(
                    "Illegal value for text rendering mode. Expected: 0-7");
        }
        if (mode != this.textRenderingMode) {
            writeTJ();
            this.textRenderingMode = mode;
            write(this.textRenderingMode + " Tr\n");
        }
    }

It seems the class org\apache\fop\render\pdf\PDFPainter.java should be modified to call setTextRenderingMode(int mode).

Intelligent2013 added a commit to metanorma/mn2pdf that referenced this issue Aug 19, 2022
Intelligent2013 added a commit to metanorma/mn2pdf that referenced this issue Aug 19, 2022
@Intelligent2013
Copy link
Contributor

mn2pdf updated for 2nd option.

@Intelligent2013
Copy link
Contributor

Issue found with the text selection.
Before update (both options) we can select the text before formula, formula and text after formula:
image

After update - the formula isn't selected:
image
but we can select the formula only:
image

Looks like the text selection feature depends on the element depth (z-order) or the rendering order.
May be we need to remove 1st option. Will check it.

@Intelligent2013
Copy link
Contributor

Now the hidden text placed at start of page, therefore we need to remove 1st option.

PDF Before update:
image

Currently generated PDF:
image

@Intelligent2013
Copy link
Contributor

1st option removed.

@Intelligent2013
Copy link
Contributor

@ronaldtse issue fixed in https://github.com/metanorma/mn2pdf/releases/tag/v1.49

Blog post updated a bit in PR metanorma/metanorma.org#640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants