Insert Page Number Issue


#1

Dear Team,

We have problem with insert page number in document. i have attached documents Please find and give as solution.
Note: Some Files Only Not Working Properly

Input File
22_Lncs116130305.zip (955.9 KB)

Source Code
Page_Number.zip (1.1 KB)

Thank you in Advance


#2

@rjnick

We have tested the scenario and have not found any issue. Could you please share the issue that you are facing while inserting the Page field? We will then provide you more information about your query.


#3

@tahir.manzoor and team,

No, I face same issue now also, Again i shared a input and out file to u,

issue scenario
some file page numbers field are not insert properly
input file
Input.zip (955.9 KB)

output file
Output.zip (918.9 KB)

Screen Shot
i attached 3 page screen shot but the issue is same in all pages
Aspose Issue_screen shot.zip (485.6 KB)


#4

@rjnick

As per our understanding, you want to insert page number at the start of each page. We suggest you please move the cursor to the header of document using DocumentBuilder.MoveToHeaderFooter method and insert the page field.

If this does not help you, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.


#5

@tahir.manzoor and Team,
I try to use “DocumentBuilder.MoveToHeaderFooter method and insert the page field.” but I am not getting expected output :disappointed:
I attached expected, actual output and input file

ISSUE.zip (2.7 MB)


#6

@rjnick

Please use the following code example to insert the page number field in the header of document. Hope this helps you.

Document inputdoc = new Document(MyDir + "input.docm");
DocumentBuilder builder = new DocumentBuilder(inputdoc);
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.write("[Page ");
builder.insertField(FieldType.FIELD_PAGE, false);
builder.write("] ");


builder.moveToHeaderFooter(HeaderFooterType.FOOTER_FIRST);
builder.write("[Page ");
builder.insertField(FieldType.FIELD_PAGE, false);
builder.write("] ");

builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN);
builder.write("[Page ");
builder.insertField(FieldType.FIELD_PAGE, false);
builder.write("] ");

inputdoc.updateFields();
inputdoc.removeMacros();
inputdoc.save(MyDir + "output.docx");

If you still want to insert the page number field in the page’s body, you need to register the hyphenation dictionary as shown below. After registering the English dictionary, the page layout will be correct and you can get the correct Run/Paragraph node at the start of page.

Hyphenation.registerDictionary("en-US", MyDir + "hyph_en_US.dic");
Document inputdoc = new Document(MyDir + "input.docm");

#7

@tahir.manzoor and team,

Hyphenation.registerDictionary(“en-US”, MyDir + “hyph_en_US.dic”);
Document inputdoc = new Document(MyDir + “input.docm”);

Above code working fine but some files also face the same issue.
I attached Screen Shots for the issue pages
Issue output.zip (393.3 KB)
Note: Expected output already sent before (Insert Page Number Issue)

Thank you in advance


#8

@rjnick

We are investigating this issue and will get back to you soon.


#9

@rjnick

In your case, the layout API does not get the correct text (Run node) at the start of page. So, you get the incorrect position of page field. We have logged this problem in our issue tracking system as WORDSNET-18825. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

After the fix of this issue, you can use the same code to insert the page field.


#10

Dear @tahir.manzoor and Team,
This is very Urgent Requirement kindly do the needful.
Thank you in advance


#11

@rjnick

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.


#12

@rjnick

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-18825) as ‘Not a Bug’.

Your problem in the document is related to hyphenation dictionary. You should perform following change in the hyph_en_US.dic:

  • Add next patterns to the bottom of the hyph_en_US.dic:
    .medi9cine.
    .surger9ies.
    .health8care.
    .un9con9ven9tion9al.
    .mil9li9me9ters.
    .mea8s9ure9ments.
    .im9por8tant.
    .ar9throplasty.
    .cer9e9bro9spi9nal.
    .spi9nal.
    .need9ed.
    .fund9ed.