We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Second Page Generate After Merge the data using Aspose Word

Hello

I have a word template with single page Fixed Header and Footer (SalesOrder1.docx).

when we merge the data into this template and convert into pdf (ORDER CONFIRMATION_1888959.pdf) it automatically create second blank page.which is unnecessary there is much space in first page repeater area.

Please look into word template and suggest what is the issue in word template.





Hi Manish,


We see that you’d generated “ORDER+CONFIRMATION_1888959.pdf” file by using Aspose.Words for .NET 15.2.0. We suggest you please upgrade to Aspose.Words for .NET 16.12.0 and see how it goes on your end:

Aspose.Words for .NET 16.12.0

In case the problem still remains, please create a standalone Console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

Best regards,

Hello I updated the aspose version, but still facing two page issue.

attach is some example.

please respond on this asap as my clients are waiting for update on this.

Hi Manish,


Thanks for your inquiry. In addition to saving to PDF, can you please save your final report to DOCX format and attach the DOCX outputs here for our reference for further testing?

// …
// …
// …
// Code that generates your reports
// Save to DOCX
doc.Save(MyDir + @“17.1.0.docx”);
// And then Save to PDF
doc.Save(MyDir + @“17.1.0.docx”);

Best regards,

See attached a word and pdf example. The attached example does not use page borders, it uses tables. If we delete empty rows in a table it does not work for us as then the formatting changes. Hence please do not suggest to delete empty rows. We just want the second page to be deleted , the first page is correct.


Can you advise why there are two pages. Is there a way we can write a code to delete the last page.

Hi,


Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @“Packing+List_MT1077-17+(1).docx”);

int pageCount = doc.PageCount;

Table table = doc.FirstSection.Body.Tables[0];

foreach (Row row in table)

{

if (string.IsNullOrEmpty(row.ToString(SaveFormat.Text).Trim()))

{

LayoutCollector collector = new LayoutCollector(doc);

if (collector.GetEndPageIndex(doc.FirstSection.Body.LastParagraph) == pageCount)

{

row.RowFormat.ClearFormatting();

foreach (Cell cell in row)

{

cell.FirstParagraph.ParagraphBreakFont.Size = 1;

}

}

else

{

break;

}

}

}

doc.Save(MyDir + @"17.1.0.docx");

doc.Save(MyDir + @"17.1.0.pdf");


Hope, this helps.

Best regards,

We have two types of documents. Some which have page borders and some which have tables. Both these types of documents give a blank second page. Please confirm that your code will resolve both these types of documents

Hello Thanks for reply but provided code generate blank rows in document.

This does not remove the Blank page which is created with Header and Footer only . There is no BODY in it . We do not want that to be generated as it is extra page . How can we do that .

We do not get the number of Product Lines in the Repetitive table .

Please check the Initial Query in this POST which tells everything and the attachment also

Second Page Generate After Merge the data using Aspose Word

Also for your reference we have sent the Standalone Application with this issue also in below ticket . Please check it :
Footer on only Last Page

Also please reply as how to implement the below:

Footer on only Last Page







I am worried did you understand my issue or not.if need more explanation.

please let me know.

Hi,


Can you please provide a Word document where the above code does not work?

Best regards,