Finding coordinates of subform within form, in specific area

383 views Asked by At

I'm using the Adobe Reader control AxAcroPdf in VB to show a pdf file within a form. In this form, there is an option to popup a subform, which shows a barcode. The user should be able to drag the subform where they want on the PDF, and upon hitting Enter, the barcode is stamped on that location where the subform was located.

So I've got the stamping down and the barcode design, but I can't seem to pinpoint the exact location this thing should go. I've tried a number of variations of this, and I can't seem to get anything to work.

'coordinates of barcodeform relative to the pdf control
Dim pt3 As Point = rdrAdobePdf.PointToClient(barCodeForm.Location)

'This comes close but is always 10-50 pixels off
Dim clientBarCode As Point = New Point(0.5 * (PointToClient(barCodeForm.Location).X - 5), (CInt(pdfReader.GetPageSize(1).Height) - PointToClient(barCodeForm.Location).Y - 80))

'Dim clientBCTry1 As Point = Point.op_Subtraction(PointToClient(screenBarCode), topLeftCorner)
'Dim clientBCtry2 As Point = rdrAdobePdf.PointToClient(screenBarCode)

I understand the basics about PointToClient and PointToScreen and I also understand the concepts of (X,Y) coordinates. Yet after days of trying things nothing works. Any help is appreciated.

1

There are 1 answers

0
Paul On

This almost seems like a hardcoded solution, but this code somewhat helps. It does position the barcode accurately if stamped at the top of the PDF page. However, if stamped toward the bottom, it becomes less and less accurate... even though the dimensions of the page don't change. If anyone has any other solutions feel free to post them.

Dim x As Integer = CInt(0.5 * (PointToClient(screenBarCode).X))
Dim y As Integer = (CInt(pdfReader.GetPageSize(1).Height) - PointToClient(screenBarCode).Y)

If x < 0 Then x = 0
If y < 0 Then y = 0

Dim clientBarCode As Point = New Point(x, y)