Free Support Forum - groupdocs.com

How to change Watermark font to minimum size in Java

hi ~
I need to set the size of the text to about 5px, but after experiments, the minimum size of the library provided by your side supports about 10px, which will not change when it goes down. May I ask if your product itself has this problem? Or is there something wrong with my implementation? (The code is as follows) In addition, if it has nothing to do with the implementation of my code, could you please help me solve the problem of font size?

    Watermarker watermarker = new Watermarker(inFilePath);
    TextWatermark textWatermark = new TextWatermark(WaterText, new Font("Arial", 8));
    textWatermark.setHorizontalAlignment(HorizontalAlignment.Center);
    textWatermark.setVerticalAlignment(VerticalAlignment.Bottom);
    textWatermark.setRotateAngle(0);
    textWatermark.setSizingType(SizingType.ScaleToParentDimensions);
    textWatermark.setScaleFactor(0.5);
    textWatermark.setOpacity(0.1);
    watermarker.add(textWatermark);
    watermarker.save(outFilePath);
    watermarker.close();

@q152625424

We’re investigating this scenario at our end. Your investigation ticket ID is WATERMARKJAVA-86. You’ll be notified as there’s any update.

@q152625424

We’ve an update on WATERMARKJAVA-86.
If we use ScaleToParentDimensions, the actual font size is calculated according to the dimensions of the parent (the document page). In your code, the watermark was enlarged to the width of the page:

textWatermark.setSizingType(SizingType.ScaleToParentDimensions);

and then reduced in half:

textWatermark.setScaleFactor(0.5);

If you remove these two scaling commands, you can get any font size.