Posted by a ceTe Software moderator
Hello,
Yes. you can rotate the pages of the already existing PDF document and then append a generated PDF document to it without any problem using our DynamicPDF Merger for .NET product. You will have to open the already existing PDF document using the PdfDocument object and then create MergeDocument object using PdfDocument object. You will have to loop through each page in the PDF document and rotate each page using the Rotate property of the Page class.
Once all the pages of the PDF document are rotated then you can create new PDF document from scratch and output it to the byte array using the Draw method of the Document class and then append this to the MergeDocument object using Append method. Please find the below code for rotating the pages in the already existing PDF document and appending a newly generated PDF Document.
PdfDocument pdf = new PdfDocument(@"C:\temp\DocumentC.pdf");
MergeDocument mergeDocument= new MergeDocument(pdf);
//The below code will rotate the pages of the already exsting PDF document to anlge 90.
for (int i = 0; i < mergeDocument.Pages.Count; i++)
{
mergeDocument.Pages[i].Rotate = 90;
}
//Below code is to generate PDF document.
Document document = new Document();
Page page = new Page(PageSize.Legal, PageOrientation.Landscape);
Label label = new Label("Page with size Legal and page orientation Landscape",100,100,400,20);
page.Elements.Add(label);
document.Pages.Add(page);
byte[] byteData = document.Draw();
//Appending the generated PDF document
mergeDocument.Append(new PdfDocument(byteData));
mergeDocument.Draw(@"C:\Temp \Test.pdf");
Thanks,
ceTe Software Support Team.