Free Support Forum - aspose.com

Watemark problem

I have a word file when I convert it to pdf and set the watermark,watermark is under the writings.I attached original file and screenshot for you.Could you please check it?

Hi Ahmet,


Thanks for your inquiry. Please share the complete code you’re using for inserting Watermark Shape before saving to PDF. I will investigate the issue on my side and provide you more information.

Best Regards,

public static void SetWaterMarkForPDF(DataConn dc, string tempFileName, HttpServerUtility su, string tip)
{

string fileName = tempFileName;
string kKopya = "KONTROLLU KOPYA";

if (kKopya != "")
{
int iFontSize = 36;

System.Drawing.Color YaziRengi = System.Drawing.Color.Red;

int iYer = 4;
int iAci = 45;
PdfFileInfo fileInfo = new PdfFileInfo(su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_.pdf");
Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();
kKopya = kKopya.Replace("ı", "i").Replace("İ", "I").Replace("ş", "s").Replace("Ş", "S").Replace("ğ", "g").Replace("Ğ", "G");
FormattedText formatText = new FormattedText(kKopya, YaziRengi, Aspose.Pdf.Facades.FontStyle.CourierBold, EncodingType.Cp1252, false, iFontSize);
aStamp.BindLogo(formatText);

float vtext = formatText.TextHeight / 2, htext = formatText.TextWidth / 2;

aStamp.IsBackground = true;
aStamp.Rotation = iAci;
float iAngel = (float)(Math.PI * iAci / 180.0);
float fx = 0, fy = 0, cons = 30;
switch (iYer)
{
case 0: fx = cons; fy = fileInfo.GetPageHeight(1) - cons;
break;
case 1: fx = fileInfo.GetPageWidth(1) / 2; fy = fileInfo.GetPageHeight(1) - cons;
break;
case 2: fx = fileInfo.GetPageWidth(1) - cons; fy = fileInfo.GetPageHeight(1) - cons;
break;
case 3: fx = cons; fy = fileInfo.GetPageHeight(1) / 2;
break;
case 4: fx = fileInfo.GetPageWidth(1) / 2; fy = fileInfo.GetPageHeight(1) / 2;
break;
case 5: fx = fileInfo.GetPageWidth(1) - cons; fy = fileInfo.GetPageHeight(1) / 2;
break;
case 6: fx = cons; fy = cons;
break;
case 7: fx = fileInfo.GetPageWidth(1) / 2; fy = cons;
break;
case 8: fx = fileInfo.GetPageWidth(1) - cons; fy = cons;
break;

default: fx = cons; fy = cons;
break;
}


fx = (float)(fx - (System.Math.Cos(iAngel) * htext));
fy = (float)(fy - (System.Math.Sin(iAngel) * htext));
if (fx < 0) fx = cons;
if (fy < 0) fy = cons;

aStamp.SetOrigin(fx, fy);

// PdfFileStamp stamper = new PdfFileStamp(su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_.pdf", su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName);
string outputFileName = su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_2.pdf";
outputFileName = su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + ".pdf";

PdfFileStamp stamper = new PdfFileStamp(su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_.pdf", outputFileName);
stamper.AddStamp(aStamp);

stamper.Close();


// System.IO.File.Delete(su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_.pdf");
//DocumentPrivilege privilege = DocumentPrivilege.AllowAll;
//PdfFileSecurity fileSecurity = new PdfFileSecurity(su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName.Substring(0, tempFileName.LastIndexOf('.')) + "_2.pdf", su.MapPath("../../QDMSFiles/TEMPFOL/") + tempFileName);
//fileSecurity.SetPrivilege(privilege);

}
}

Hi Ahmet,


Thanks for your inquiry. I feel your query is more related to Aspose.PDF, I will move your request in Aspose.PDF forum. My colleagues from Aspose.PDF component team will answer you shortly.

Alternatively, you may also try adding a watermark inside a Word document using Aspose.Words. Once the watermark is added, you can then convert this Word document to PDF format. In this case the resultant PDF will contain the watermark image. Please read the following article for more details:
http://www.aspose.com/docs/display/wordsnet/How+to++Add+a+Watermark+to+a+Document

Best Regards,

Hi Ahmet,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 7.4.0 and I am unable to notice any issue. Watermark and page contents are properly being displayed. Can you please share the source PDF file which you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

I tried with 7.4 version.But result is same.First,I am converting .doc document to pdf ,then I am using watermark.I attached my original file TL-7.5.2-188-D STEP-LAP.doc.

Hi Ahmet,


Thanks for sharing the details.

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-34490. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

Hi Nayyer,


I have rendered TL-7.5.2-188-D+STEP-LAP.doc document to Pdf format by using the latest version of Aspose.Words i.e. 11.9.0 on my side and attached the Pdf here for your reference.

Best Regards,

Hi Awais,


Thanks for sharing the document.

I have again tested the scenario and problem is also appearing when using the output generated with Aspose.Words for .NET 11.9.0. The development team will further investigate this issue and hopefully they will be able to figure out the reasons of this problem.

Hi,

Do you have any improvement?

Hi Ahmet,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<o:p> </o:p>

Thank you for being patient.

Our development team has further looked into your issue and following is their feedback.

<o:p></o:p>

Text in your file has white color areas due to which stamp is overdrawn by text. To make stamp visible and not overlapped by text area you may use Stamp.IsBackground = false to show stamp over text. Also set opacity to avoid hiding stamp under text. Please see the following updated code (Changes are marked in Bold).

string kKopya = "KONTROLLU KOPYA";

if (kKopya != "")

{

int iFontSize = 36;

System.Drawing.Color YaziRengi = System.Drawing.Color.Red;

int iYer = 4;

int iAci = 45;

PdfFileInfo fileInfo = new PdfFileInfo(@"D:\TL-7.5.2-188-D+STEP-LAP.pdf");

Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();

kKopya = kKopya.Replace("ı", "i").Replace("İ", "I").Replace("ş", "s").Replace("Ş", "S").Replace("ğ", "g").Replace("Ğ", "G");

FormattedText formatText = new FormattedText(kKopya, YaziRengi, Aspose.Pdf.Facades.FontStyle.CourierBold, EncodingType.Cp1252, false, iFontSize);

aStamp.BindLogo(formatText);

float vtext = formatText.TextHeight / 2, htext = formatText.TextWidth / 2;

aStamp.IsBackground = false;

aStamp.Opacity = 0.3f;

aStamp.Rotation = iAci;

float iAngel = (float)(Math.PI * iAci / 180.0);

float fx = 0, fy = 0, cons = 30;

switch (iYer)

{

case 0: fx = cons;

fy = fileInfo.GetPageHeight(1) - cons;

break;

case 1: fx = fileInfo.GetPageWidth(1) / 2;

fy = fileInfo.GetPageHeight(1) - cons;

break;

case 2: fx = fileInfo.GetPageWidth(1) - cons;

fy = fileInfo.GetPageHeight(1) - cons;

break;

case 3: fx = cons;

fy = fileInfo.GetPageHeight(1) / 2;

break;

case 4: fx = fileInfo.GetPageWidth(1) / 2;

fy = fileInfo.GetPageHeight(1) / 2;

break;

case 5: fx = fileInfo.GetPageWidth(1) - cons;

fy = fileInfo.GetPageHeight(1) / 2;

break;

case 6: fx = cons;

fy = cons;

break;

case 7: fx = fileInfo.GetPageWidth(1) / 2;

fy = cons;

break;

case 8: fx = fileInfo.GetPageWidth(1) - cons;

fy = cons;

break;

default: fx = cons;

fy = cons;

break;

}

fx = (float)(fx - (System.Math.Cos(iAngel) * htext));

fy = (float)(fy - (System.Math.Sin(iAngel) * htext));

if (fx < 0) fx = cons;

if (fy < 0) fy = cons;

aStamp.SetOrigin(fx, fy);

string outputFileName = @"D:\TL-7.5.2-188-D+STEP-LAP_Stampped.pdf";

PdfFileStamp stamper = new PdfFileStamp(@"D:\TL-7.5.2-188-D+STEP-LAP.pdf", outputFileName);

stamper.AddStamp(aStamp);

stamper.Close();

}

Attached is the generated file for reference.

Sorry for the inconvenience,

Thank you…

The issues you have found earlier (filed as PDFNEWNET-34490) have been fixed in Aspose.Pdf for .NET 7.6.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.