The code below creates a new PDF with landscape orientation. It uses ABCPdf component.
static void Main(string[] args)
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "da.pdf");
var theDoc = new Doc();
//theDoc.Read(filePath);
// apply a rotation transform
theDoc.MediaBox.String = "Legal";
double w = theDoc.MediaBox.Width;
double h = theDoc.MediaBox.Height;
double l = theDoc.MediaBox.Left;
double b = theDoc.MediaBox.Bottom;
theDoc.Transform.Rotate(90, l, b);
theDoc.Transform.Translate(w, 0);
// rotate our rectangle
theDoc.Rect.Width = h;
theDoc.Rect.Height = w;
// add some text
theDoc.Rect.Inset(50, 50);
theDoc.FontSize = 96;
theDoc.AddText("Landscape Orientation");
theDoc.AddPage();
theDoc.PageNumber = theDoc.PageCount;
theDoc.AddText("Page 2");
// adjust the default rotation and save
int theID = theDoc.GetInfoInt(theDoc.Root, "Pages");
theDoc.SetInfo(theID, "/Rotate", "90");
theDoc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "out.pdf"));
theDoc.Clear();
}
Instead of creating new pdf, I would like to open an existing PDF and change the orientation of a specific page to landscape using ABCPdf. like 1st page will be in Portrait and 2nd will be on Landscape.
Thanks