Skip to main content
Participating Frequently
September 3, 2018
Answered

Fix position of form fields containing page numbers

  • September 3, 2018
  • 1 reply
  • 1883 views

Dear community,

I have an Excel VBA macro which adds page numbers to certain pdf documents.

Here an example of how this generally looks like:

Set AcroApp = CreateObject("AcroExch.App")
Set KurzGesamt = CreateObject("AcroExch.PDDoc")
  
KurzGesamt.Open (strPfadVerteilungEndlauf & strNameKurzGesamt)
Set jso = KurzGesamt.GetJSObject
intSeiten = KurzGesamt.GetNumPages
  
For i = 2 To intSeiten
      
    Set objTextfeld = jso.AddField("Textfeld" & i, "text", i - 1, Array(810, 15, 830, 25))
    objTextfeld.Value = Str(i)
    objTextfeld.textSize = 10
    objTextfeld.textFont = "Calibri"
  
Next i
  
jso.FlattenPages
  
Call KurzGesamt.Save(1, strPfadVerteilungEndlauf & strNameKurzGesamt)

KurzGesamt.Close

This code has worked perfectly for the last months but now, suddenly, I have the following problem:

Before, all form fields (containing the page numbers) were at the bottom on the right side of each page. (I got the "Array" values from above by trial and error.)

Now, the position is only correct on empty pages of the documents, while on the others, the page numbers are smaller and rather at the center of the page than on the right side.

It seems like font and position are adjusting to the respective page.

However, in the original pdfs nothing has changed and before, using the same code, this was not the case.

Therefore, my questions are:

1. Is there any setting in the Acrobat 7.0 I have to change in order to place the form fields independently from the remaining text and

2. if so, how can I define this as standard setting or change it via VBA?

3. If the problem has nothing to do with Acrobat settings, how must I change my VBA code to get the correct form field position and font size?

By the way, I've already tried to uninstall and reinstall Acrobat 7.0, because I thought, I'd maybe changed any setting accidentially, but this did not solve the problem.

Thank you in advance for any help!

This topic has been closed for replies.
Correct answer Bernd Alheit

Okay, this is the result:

0 0,619.75,877.1300048828125,0

1 0,804,1137.8900146484375,0

2 0,804,1137.8900146484375,0

3 0,762.77001953125,1079.5400390625,0

4 0,804,1137.8900146484375,0

5 0,804,1137.8900146484375,0

6 0,804,1137.8900146484375,0

7 0,804,1137.8900146484375,0

8 0,804,1137.8900146484375,0

9 0,804,1137.8900146484375,0

10 0,804,1137.8900146484375,0

11 0,804,1137.8900146484375,0

12 0,804,1137.8900146484375,0

13 0,804,1137.8900146484375,0

14 0,804,1137.8900146484375,0

15 0,804,1137.8900146484375,0

16 0,804,1137.8900146484375,0

17 0,804,1137.8900146484375,0

18 0,804,1137.8900146484375,0

19 0,804,1137.8900146484375,0

20 0,804,1137.8900146484375,0

21 0,849.9400024414062,1202.9100341796875,0

undefined


This are not A4 pages.

For a A4 page you will get:

0,842,595,0

1 reply

Bernd Alheit
Community Expert
Community Expert
September 3, 2018

Have all pages the same page size?

Participating Frequently
September 3, 2018

Yes, all pages have DIN A4 format.

Bernd Alheit
Community Expert
Community Expert
September 3, 2018

What did you get when you execute following in the Acrobat console?

console.show();

for (var p = 0; p < this.numPages; p++) {

  console.println(p + " " + this.getPageBox( {nPage: p} ));

}