PDF Tookit - Add simple graphics and get text width

Attached is another PDF (src and stamped files) where the stamp is not getting placed correctly. This may help having more pdfs to test…

Hi Jon,

Thank you very much for sharing additional PDF file. This will definitely help us in understanding the problem.

I would just like to ask one more thing, please: With this latest file, the stamp is not being applied at all. Is it? Please share your thoughts so we could proceed on this matter.

We’re sorry for the inconvenience.
Regards,

I believe it is being applied, if you look closely in the upper right corner (of the _stamped.pdf file), you can see some black text on the right side bleeding off the edge...

Hi Jon,

Thank you for pointing this out. I have noticed a very little portion is visible on the edge. We’ll investigate the issue in detail and update you accordingly.

We’re sorry for the inconvenience.
Regards,

Hi Jon,

I have updated the issue mentioned earlier, and informed our development team. Hopefully, the problem with this file will be resolved as the issue mentioned earlier is fixed.

We appreciate your patience.
Regards,

The issues you have found earlier (filed as 10763) have been fixed in this update.


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

I retested using the PDF samples and it appears the issues still remain.

Hi Jon,

You need to modify your code a little bit as well. Now, we have introduced two new methods as GetPageXOffset and GetPageYOffset in FileInfo class. You need to modify the following statement
iOffset = 30; with iOffset = 30 + fileInfo.GetPageYOffset(i);


I hope this will help. If you still find any problem, please do let us know.
Regards,



I added the new method (GetPageYOffset) and one of my PDFs still isnt displaying correctly, the other one is OK. I attached the original and the stamped versions. And where does the GetPageXOffset come into play? By adding or subtracting this value from the StampX causes the stamp to be in the wrong location as well. As a result, I guess I dont really understand the 2 new methods and how they are supposed to be used.

Hi Jon,

I have modified the following line of code:

StampX = iPageWidth - (200 + 30 + fileInfo.GetPageXOffset(i));

The output file is also attached. The stamp is being applied properly. Are you trying to apply the stamp where it is right now?

I hope this helps. If you still find any issue, please do let us know.
Regards,

Using the same sample code earlier in this post, I am getting a very large value when calling the fileInfo.GetPageYOffset(i) for sample 2.pdf (see attached test_docs.zip). I am getting value around 5807 which I know is not correct causing the stamp to not appear.

Sample 1.pdf stamps just fine. sample code below

static void gemini_7514()

{

FileStream aFS = new FileStream(@"D:\Temp\test\stamp\2.pdf", FileMode.Open, FileAccess.Read);

FileStream aMS1 = new FileStream(@"D:\Temp\test\stamp\2_stamped.pdf", FileMode.Create, FileAccess.Write);

String[] sStamp = new string[4] { "APPROVED", "Date Received: Date Of Action:", "11/25/2001 12/10/2002", "MY OFFICE OF INSURANCE REGULATION" };

PdfFileInfo fileInfo = new PdfFileInfo(aFS);

int numPages = fileInfo.NumberofPages;

PdfFileStamp aPFS2 = new PdfFileStamp(aFS, aMS1);

for (int i = 1; i <= numPages; i++)

{

float iTextWidth = 0; float iTextHeight = 0;

//Get height, width and rotation of the current page

float iPageHeight = 0; float iPageWidth = 0; int iRotation = 0;

iPageHeight = fileInfo.GetPageHeight(i);

iPageWidth = fileInfo.GetPageWidth(i);

iRotation = fileInfo.GetPageRotation(i);

float StampX = 0; float StampY = 0; float iOffset = 0;

StampX = iPageWidth - (200 + 30 + fileInfo.GetPageXOffset(i));

StampY = iPageHeight - (80 + 30);

iOffset = 30 + fileInfo.GetPageYOffset(i);

for (int k = 0; k < sStamp.Length; k++)

{

Stamp logoStamp = new Stamp();

FormattedText formatText = new FormattedText(sStamp[k], System.Drawing.Color.FromArgb(255, 0, 0), "Arial", EncodingType.Winansi, true, 8);

logoStamp.BindLogo(formatText);

logoStamp.Rotation = -5;

iTextWidth = formatText.TextWidth; iTextHeight = formatText.TextHeight;

logoStamp.SetOrigin(StampX + (200 - iTextWidth) / 2, iPageHeight - iOffset);

logoStamp.PageNumber = i; //Note: a new property Stamp.PageNumber is added since this version

iOffset = iOffset + iTextHeight + 4;

aPFS2.AddStamp(logoStamp);

}

}

aPFS2.Close();

aFS.Close();

aMS1.Close();

}

Hi Jon,

I have reproduced this problem at my end and logged it as PDFKITNET-24038 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,