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

Free Support Forum - aspose.com

Last page data overflowing to next page while appending docx and converting to pdf

651045772122222071314941.pdf (8.2 MB)
FIA-1140 (B) Tagged.docx (88.8 KB)
FIA-1140 (E)_Tagged.docx (87.2 KB)
HRA-102c (B)_Tagged.docx (230.9 KB)
HRA-102c (E)_Tagged.docx (227.4 KB)

@bhanu410 The problem occurs because your document were created using different version of MS Word and as a result have different set of compatibility options. When you concatenate the documents compatibility options of the main document are applied and the content is reflowed appropriately.
You can workaround this and convert each document to PDF and then concatenate them using Aspose.PDF:

string[] docs = new string[] {
    @"C:\Temp\FIA-1140 (B) Tagged.docx",
    @"C:\Temp\HRA-102c (B)_Tagged.docx",
    @"C:\Temp\FIA-1140 (E)_Tagged.docx",
    @"C:\Temp\HRA-102c (E)_Tagged.docx"

Document target = null;
int i = 0;
foreach (string path in docs)
    Document doc = new Document(path);
    doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;
    doc.Save(string.Format(@"C:\Temp\out_{0}.pdf", i++));

I tried above workaround but getting the error below
At most 4 elements (for any collection) can be viewed in evaluation mode

@bhanu410 It looks like you are using Aspose.PDF in evaluation mode. You should apply the license for both Aspose.Words and Aspose.PDF products. Please see our documentation for more information:

Hi @alexey.noskov, We only have license for Aspose.Words, is there any alternate solution apart from this workaround?

Thanks in advance.

@bhanu410 Unfortunately, there is no other good workaround of this issue. We are working on providing a functionality to merge PDF document using Aspose.Words. This functionality will be available in on of future versions of Aspose.Words for .NET. We will keep you informed and let you know once it is available.

@alexey.noskov thanks for the help

1 Like

The issues you have found earlier (filed as WORDSNET-24246) have been fixed in this Aspose.Words for .NET 23.2 update also available on NuGet.

@bhanu410 With the latest 22.2 version of Aspose.Words you can use the following code to merge PDF documents without parsing them into Aspose.Words DOM:

Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer pdfFixedRenderer = new Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer();

using (FileStream pdf1 = File.OpenRead(@"C:\Temp\in1.pdf"))
using (FileStream pdf2 = File.OpenRead(@"C:\Temp\in2.pdf"))
    using (Stream resultStream = pdfFixedRenderer.MergePdf(pdf1, pdf2))
    using (FileStream resultFile = File.Create(@"C:\Temp\out.pdf"))