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

Free Support Forum - aspose.cloud

How to add page numbers to the merged PDF document?

Hi,

We are looping in and converting each excel and word template into PDF using Aspose.PDF.Cloud.SDK( Having if conditions where the extension = .docx and .xls etc , also handling the case where the extension = .pdf) and then merging all the converted PDF’s into one single PDF document. I need the page numbers to be added to this final PDF document. How can I accomplish this?

Any help is greatly appreciated. Thank you in advance.

@s2205,

Please reference to Merge | Aspose.Cells Cloud Document.
And We will provide some detailed code examples.

Hi @wangtao, thank you for your response. I have been experimenting all day with the below code snippet ( added this code after the merging of PDF is completed)

PageNumberStamp stamp = new PageNumberStamp()
{
Background = true,
LeftMargin = 1,
RightMargin = 2,
TopMargin = 3,
BottomMargin = 4,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
Opacity = 1,
Rotate = Rotation.None,
RotateAngle = 0,
XIndent = 0,
YIndent = 0,
Zoom = 1,
StartingNumber = 1,
Value = “Page #”

                            };
                            var response = pdfApi.PostDocumentPageNumberStamps(destFileName, stamp, startPageNumber: 1, ' ', storage, folder);

But this is not generating the numbers for all the pages. I noticed that if the document is 64 pages, then it is only generating the page numbers until 32. What am I missing here? Could you please provide the code snippet for achieving this functionality. That’ll be very helpful.

Regards
SLS

@s2205,
e.g.

string InputFolder = @“D:\projects\test\Aspose.Cells.Cloud\TestData\source”;
LiteCellsApi cellsApi = new LiteCellsApi(“a73d6131-1f51-4fde-bc2e-bd499ed3fc22”, “b770daf30685a37aa61c08ddcbf232b2”);
IDictionary<string, Stream> dirFiles = new Dictionary<string, Stream>();
dirFiles.Add(“Book1.xlsx”, File.OpenRead(InputFolder + “Book1.xlsx”));
dirFiles.Add(“Book2.xlsx”, File.OpenRead(InputFolder + “Book2.xlsx”));
var resFileInfo = cellsApi.PostMerge(dirFiles, “pdf”, false);
using ( Stream stream = File.Create(resFileInfo.Filename))
{
byte[] data = System.Convert.FromBase64String(resFileInfo.FileContent);
stream.Write(data, 0, data.Length);
}

1 Like

Thank you @wangtao

@s2205,

1, your excel files set the footer for all sheets.
2, you first merge these excel files into an Excel file and convert the merged Excel file to PDF.

It will be generating the numbers for all the pages.

if you first convert these excel files to pdf files and merge these pdf files into a pdf file, you need to post the issue into https://forum.aspose.cloud/c/pdf/