Rotate page before inserting in multi-up PDF

Hello,

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.
This is our code:
     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")

Regards,
Wim
              

11 Replies

SL Sowmiya Loganathan Syncfusion Team December 24, 2020 01:59 PM UTC

Hi Programming,   

Thank you for contacting Syncfusion support.   

We have analyzed your requirement “Rotate page an existing PDF document before inserting to PDF document” and created the sample to achieve this. Please find the download link for the same from below,   


Please try the above sample in your end and let us know the result.   

Regards,  
Sowmiya Loganathan 



PR programming December 28, 2020 07:47 AM UTC

Hello,

Thanks for the reply but it's not the solution we need. 
We need to add 4 pages A6 on one A4 page, the A6 pages can be a landscape or portrait page. 
See attachment for output sample.

Regards
Wim

Attachment: Output_sample_1304b722.7z


SL Sowmiya Loganathan Syncfusion Team December 29, 2020 03:58 PM UTC

Hi Wim,   
  
Thank you for the details.   
  
Currently we are creating the sample to achieve your requirement and will update the further details on December 30, 2020.   
  
Regards,  
Sowmiya Loganathan  




SL Sowmiya Loganathan Syncfusion Team December 30, 2020 12:53 PM UTC

Hi Wim, 

Thank you for your patience.  

We have created the sample to achieve your requirement and please find the download link for the same from below,  


Regards, 
Sowmiya Loganathan 





PR programming January 7, 2021 10:48 AM UTC

Hello,

This solution is not working, the rotated pages are scaled disproportional.

Regards
Wim


SL Sowmiya Loganathan Syncfusion Team January 8, 2021 12:29 PM UTC

Hi Wim,   
 
We have modified the sample and please find the download link from below,   
 
 
Please let us know if you have any concerns on this.   
 
Regards,  
Sowmiya Loganathan  



PR programming January 12, 2021 02:17 PM UTC

Hello,

Still the same problem, see attachment.

Regards
Wim

Attachment: Screenshot_20210112_151427_c32e5701.7z


SL Sowmiya Loganathan Syncfusion Team January 13, 2021 12:34 PM UTC

Hi Wim,  

In the previous update, we have created the sample to add A4 page (split into 4) with A6 pages with rotation as like the PDF document which has been provided by you. Could you please provide us the below details regarding the details about your requirement, it will helpful for us to provide the precise solution on this.  
 
  • Further details about your requirement
  • Expected output
 
Regards, 
Sowmiya Loganathan 



PR programming January 13, 2021 01:40 PM UTC

Hello,

The rotated pdf in your samples is scaled disproportional.
The expected output is that the rotated pdf keeps his original size.
See files in attach.

Regards
Wim

Attachment: samples_ab356db0.zip


GK Gowthamraj Kumar Syncfusion Team January 14, 2021 09:32 AM UTC

Hi Wim,    
   
Thank you for sharing the details.    
   
Currently, we are creating the sample to achieve your requirement in our end and we will update the further details on January 15th , 2021.    

Regards, 
Gowthamraj K 



SL Sowmiya Loganathan Syncfusion Team January 18, 2021 12:56 PM UTC

 
Hi Wim,   
 
We have created a new incident under your Direct trac account . We suggest you to follow up with the incident for further updates. Please log in using the below link.  
 
Regards,  
Sowmiya Loganathan 


Loader.
Up arrow icon