I'm trying to merge multiple pdf files, each of those has a different page size. First file has A4 size, the othes are different (in general).
When I use PdfDocument.MergeFiles all pages of the result pdf are A4 size.
I have also tried the following way, with no success. Pages remain A4 size.
- Code: Select all
// doc = new Spire.Pdf.PdfDocument(files.First().Content); file where all pages are A4 size
byte[] content = File.ReadAllBytes(filename); // file with different size than A4
Spire.Pdf.PdfDocument tempDoc = new Spire.Pdf.PdfDocument(content);
foreach (Spire.Pdf.PdfPageBase page in tempDoc.Pages)
{
Spire.Pdf.PdfPageBase newPage = doc.Pages.Add(page.Size, new Spire.Pdf.Graphics.PdfMargins(0));
Spire.Pdf.Graphics.PdfMetafileLayoutFormat loLayout = new Spire.Pdf.Graphics.PdfMetafileLayoutFormat();
loLayout.Layout = Spire.Pdf.Graphics.PdfLayoutType.OnePage;
loLayout.Break = PdfLayoutBreakType.FitPage;
page.CreateTemplate().Draw(newPage, new PointF(0, 0), loLayout);
}
For every pdf I'd like to keep the original size. How can I do that?
Thanks in advance,
Elia