We need to multi-up some pdf's, all same format (A6) but some landscape and some portrait.
Multi-up is 2 by 2 on A4.
on screen the rotate works, but when inserting in the multi-up it not rotated.
Dim lstPdfs As New List(Of String)
lstPdfs.Add("C:\test\in\Pdf1.pdf")
lstPdfs.Add("C:\test\in\2pagesPDF.pdf")
lstPdfs.Add("C:\test\in\Pdf2.pdf")
lstPdfs.Add("C:\test\in\Pdf3.pdf")
lstPdfs.Add("C:\test\in\Pdf4.pdf")
lstPdfs.Add("C:\test\in\Pdf5.pdf")
lstPdfs.Add("C:\test\in\2pagesPDF.pdf")
lstPdfs.Add("C:\test\in\Pdf6.pdf")
Dim OutDocument As PdfDocument = New PdfDocument()
OutDocument.PageSettings.Orientation = PdfPageOrientation.Portrait
OutDocument.PageSettings.Margins.All = 0
OutDocument.PageSettings.Size = PdfPageSize.A4
Dim page As PdfPage = OutDocument.Pages.Add()
Dim No_of_columns_per_Row As Int16 = 2
Dim No_of_Rows_per_Page As Int16 = 2
Dim TemplateWidth As Double = Convert.ToDouble(OutDocument.Pages(0).Size.Width / No_of_columns_per_Row)
Dim TemplateHeight As Double = Convert.ToDouble(OutDocument.Pages(0).Size.Height / No_of_Rows_per_Page)
Dim TemplateX As Double = 0
Dim TemplateY As Double = 0
Dim template As PdfTemplate = Nothing
Dim intInsertedPages As Integer = 0
For i As Int16 = 0 To lstPdfs.Count - 1
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument(lstPdfs(i))
For j As Int16 = 0 To ldoc.Pages.Count - 1
If intInsertedPages >= No_of_columns_per_Row AndAlso intInsertedPages Mod No_of_columns_per_Row = 0 Then
If intInsertedPages Mod 4 <> 0 Then
TemplateY += TemplateHeight
End If
TemplateX = 0
End If
Dim LoadedPage As PdfPageBase = ldoc.Pages(j)
If LoadedPage.Size.Width > LoadedPage.Size.Height Then
'ROTATE PAGE
'THIS IS NOT WORKING:
LoadedPage.Rotation = PdfPageRotateAngle.RotateAngle270
'if we save the document, page is rotated in original document 'ldoc' but this page is not rotated in 'OutDocument'
'ldoc.Save()
End If
template = LoadedPage.CreateTemplate()
page.Graphics.DrawPdfTemplate(template, New PointF(TemplateX, TemplateY), New SizeF(TemplateWidth, TemplateHeight))
TemplateX += TemplateWidth
If intInsertedPages Mod 4 = 3 AndAlso (i < lstPdfs.Count - 1 Or j < ldoc.Pages.Count - 1) Then
page = OutDocument.Pages.Add()
TemplateX = 0
TemplateY = 0
End If
intInsertedPages += 1
Next
ldoc.Close(True)
Next
OutDocument.Save("C:\test\out.pdf")
Process.Start("C:\test\out.pdf")