Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Apr 28, 2017 9:32 am

Hello,
I have this code:

ParHdr.AppendField("page number", FieldType.FieldPage).ApplyCharacterFormat(fCourier8)
ParHdr.AppendText("/").ApplyCharacterFormat(fCourier8)
ParHdr.AppendField("number of pages", FieldType.FieldNumPages).ApplyCharacterFormat(fCourier8)
ParHdr.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right

fCourier8 is defined so:
Dim fCourier8 As New Spire.Doc.Formatting.CharacterFormat(MacroCedola)
With fCourier8
.FontName = "Courier New"
.FontSize = 8
.Bold = True
End With

fCourier8 applied to the field FieldNumPages works,
fCourier8 applied to the field FieldPage does not work.


Moreover,
I have to put the number of page/pages in a textbox to give it an exact position.
This is my code:

Dim hdr As Spire.Doc.HeaderFooter = MacroCedola.Sections(0).HeadersFooters.Header
Dim ParHdr As Paragraph = hdr.AddParagraph

Dim tbPagina As TextBox = ParHdr.AppendTextBox(55, 15)
tbPagina.Format.HorizontalPosition = 775
tbPagina.Format.VerticalPosition = 20
tbPagina.Format.LineColor = Drawing.Color.Black
tbPagina.Format.FillColor = Drawing.Color.LightGray
tbPagina.ApplyCharacterFormat(fCourier8)

Dim parPagina As Paragraph = tbPagina.Body.AddParagraph()
parPagina.AppendField("page number", FieldType.FieldPage).ApplyCharacterFormat(fCourier8)
parPagina.AppendText("/").ApplyCharacterFormat(fCourier8)
parPagina.AppendField("number of pages", FieldType.FieldNumPages).ApplyCharacterFormat(fCourier8)
parPagina.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center
parPagina.Format.Borders.Space = 0
parPagina.Format.AfterSpacing = 0
parPagina.Format.BeforeSpacing = 0

See attached the result, the number of page/pages is not well visible, there seems to be a space between the paragraph and the textbox.


Can you please help me?
thank you,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Fri Apr 28, 2017 10:30 am

Hello,

Thanks for your inquiry.
After an initial test with the newst version(Spire.Doc Pack Version:5.9), both of the two fields work well at my end. Please upgrade your dlls first and try again.

Sincerely,
Jane
E-iceblue support team
Last edited by Jane.Bai on Mon May 01, 2017 6:57 am, edited 1 time in total.
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Fri Apr 28, 2017 12:18 pm

Hello Jane,
thank you very much for your answer.
We have Spire.Office platinum package 2.15, with two licences: for Spire.doc and Spire.pdf.
Can I download the Spire.doc pack version 5.9 you suggested me with no problems?
thank you in advance,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Mon May 01, 2017 6:51 am

Hello,

Please use the corresponding dlls in our newest version of Spire.Office( Spire.Office Platinum (Hot Fix) Version:2.15.8).
If there are any questions, please write back to us.

Sincerely,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue May 02, 2017 7:26 am

Hello Simon,
I downloaded the nweest versione of Spire.Office,
it works well but about the format of the Spire.Doc.FieldType.FieldPage, the problem persists.

To solve the problem, I tried to save it in a common variable:
Dim NumOfPage As Int32 = Spire.Doc.FieldType.FieldPage
it would be '1' for the first page of course, but the variable NumOfPage results to be '33'!!!

How can I save the field Spire.Doc.FieldType.FieldPage in a variable, int32 or string?

thank you,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Tue May 02, 2017 10:25 am

Hello,

Thanks for your feedback.
In Spire.Doc, the FiledType is an eum, so the result "33" you got from the code
Code: Select all
Dim NumOfPage As Int32 = Spire.Doc.FieldType.FieldPage
is in fact the related eum number of the fieldPage. In regards to your requirement of getting the value of the filed, sorry it is impossible at present since it's always dynamic.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Doc