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,
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,
Hi Ahmet,
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,
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.
apologize for your inconvenience.
Hi Nayyer,
Hi Awais,
Hi,
Do you have any improvement?
Hi Ahmet,
Thank you for being patient.
Our development team has further looked into your issue and the following is their feedback.
Text in your file has white color areas due to which the stamp is overdrawn by text. To make the stamp visible and not overlapped by the text area, you may use Stamp.IsBackground = false
to show the stamp over the text. Also set opacity to avoid hiding the stamp under the text. Please see the following updated code (Changes are marked in bold).
string kKopya = "KONTROLLU KOPYA";
if (kKopya != "") {
int iFontSize = 36;
System.Drawing.Color YazıRengi = 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,
YazıRengi,
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)(System.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.