Free Support Forum - groupdocs.com

Conversion .pdf to .png (or .jpeg) with watermark as background issue


#1

Hi,
I’d like to report an issue with conversion .pdf to .png (or jpeg) when I want to apply watermark as background.

I am setting the following value:
ImageSaveOptions.WatermarkOptions.Background = true

Example project with required documents is attached. (I removed GroupDocs.Conversion.dll)
Watermark Issue.zip (992.8 KB)

Component is for .NET v18.11

Can you please advise me?

Kind regards


#2

@SwdS_User,

We can successfully convert the PDF to PNG or JPEG without any issue using following code:

ConversionHandler conversionHandler = Common.getConversionHandler(); 
var saveOptions = new ImageSaveOptions
{
    ConvertFileType = outputFileType,
    WatermarkOptions =
    {
          Background = true,
          Transparency = 0.01,
          Text = "THIS IS WATERMARK",
          Color = Color.Aqua,
          Font = new Font("Arial", 75),
    }
}; 
using (var sourceStream = File.Open(Common.inputGUIDFile, FileMode.Open))
{
     var convertedDocumentPath = conversionHandler.Convert(sourceStream, saveOptions);
     for (int pagenum = 1; pagenum <= convertedDocumentPath.PageCount; pagenum++)
     { 
          convertedDocumentPath.Save("result-" + Path.GetFileNameWithoutExtension(Common.inputGUIDFile) + pagenum.ToString() + "." + outputFileType, pagenum);
     }
}

You can see output files here. Can you please share the exception you are facing? We observed that you are converting a PDF (with more than 3 pages) in trial mode (without applying license). Please note that there are evaluation limitations. That is why you have evaluation tag in your output.
However, in order to convert PDF successfully, you can request a temporary licence. Please follow the wizard and on step 5 you can get a temporary license.


#3

Thank you for your reply, but you just confirmed the problem.

The problem is with Watermark (WatermarkOptions.Background = true), even in your output result the watermark is over the text, and should be under the text, shouldn’t it?

Ps. I already have the licence, but I wanted to show you very simple example.

Kind regards


#4

@SwdS_User,

Yes it should, we observed this behavior and logged this issue with ID : CONVERSIONNET-2864. We are further investigating it. As we have any update, we shall notify you.


#5

@SwdS_User,

We have an update for you regarding ticket ID : CONVERSIONNET-2864. This issue will be resolved in upcoming release of the API. We’ll notify you as release gets on-board.


#6

First thank you for keeping me up to date.

I have another watermark related question. I am unable to set linebreak in watermark text
Is there a way to create a multiline text watermark?

WatermarkOptions =
{
          Text = "THIS IS WATERMARK \r\n THIS IS WATERMARK \r\n ",
          Background = true,
          Transparency = 0.01,
          Color = Color.Aqua,
          Font = new Font("Arial", 75),
}

#7

@SwdS_User,

You can add multi-line text watermark as follows:

WatermarkOptions =
{
    Background = true,
    Transparency = 0.01,
    Left = 50,
    Text = "First line" + Environment.NewLine + "second line",
    Color = Color.Red,
    Font = new Font("Arial", 25),
}

See the output - result-PDFsample1.Png (78.8 KB)


#8

Unfortunately your code does not work when I try to convert simple .docx to .pdf with watermark.

Can you please advise me?

Kind regards


#9

@SwdS_User,

We reproduced this at our end as well. We are futher investigating this. Your investigation ticket ID is CONVERSIONNET-2884. As we have any further update, we shall notify you.


#10

@SwdS_User,

We are pleased to inform you that your reported issue CONVERSIONNET-2864 is now resolved in version 19.1. We’d recommend you to download and integrate latest release of the API and share your feedback.

However, CONVERSIONNET-2884 is still under investigation. We’ll notify you as we have any further update on it.