We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Watermark replacement font

Hi,
I used this piece of code for text replacement in a header and trying to do the same for a watermark but there are no TextEditOptions. Can you please look if it possible to do it?
Regards,

                TextEditOptions =
                    new TextEditOptions(TextEditOptions.NoCharacterAction.UseCustomReplacementFont)
                    {
                        ReplacementFont = FontRepository.FindFont(headerData.DefaultSubstitutionFontName)
                    }

@gwert

Would you kindly share sample PDF document which you are trying to modify. We will test the scenario in our environment and address it accordingly.

HI,
Here is the PDF sample
watermarkPDF.pdf (130.9 KB)

Hi,
To be more accurate:
we are using TextEditOptions for TextSegment

var segment = new TextSegment(lastText)
{
    TextState = new TextState
    {
        FontStyle =
            !string.IsNullOrEmpty(cell.Texts.Last().Key)
                ? FontStyles.Bold
                : cell.FontStyle == FontStyle.Italic
                    ? FontStyles.Italic
                    : FontStyles.Regular,
        FontSize = cell.FontSize,
        Font = FontRepository.FindFont(!string.IsNullOrEmpty(cell.FontName)
            ? cell.FontName
            : headerData.DefaultFontName)
    },
    TextEditOptions =
        new TextEditOptions(TextEditOptions.NoCharacterAction.UseCustomReplacementFont)
        {
            ReplacementFont = FontRepository.FindFont(headerData.DefaultSubstitutionFontName)
        }
};

is there a way to use the same kind of TextEditOptions for the TextStamp?

var textStamp = new TextStamp(formattedText)
{
    Scale = false,
    WordWrap = true,
    Opacity = textStampWatermarkData.Opacity,
    TextAlignment = HorizontalAlignment.Center,
    Height = watermarkHeight,
    MaxRowWidth = watermarkWidth, //WordWrap needs this
    HorizontalAlignment = HorizontalAlignment.Center,
    TextState =
    {
        Font = FontRepository.FindFont(!string.IsNullOrEmpty(textStampWatermarkData.FontName)
            ? textStampWatermarkData.FontName
            : textStampWatermarkData.DefaultFontName),
        FontSize = textStampWatermarkData.FontSize,
        FontStyle = textStampWatermarkData.FontBold ? FontStyles.Bold : FontStyles.Regular,
        ForegroundColor = Color.FromRgb(System.Drawing.ColorTranslator.FromHtml(textStampWatermarkData.FontColor))
    }
};

@gwert

Thanks for providing details.

We have logged an enhancement request as PDFNET-47868 in our issue tracking system. We will surely investigate whether your required functionality can be implemented or not and keep you informed with the status of its availability. Please be patient and spare us some time.

We are sorry for the inconvenience.