Example #1
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));

            // The default page rotation is set to portrait in the custom event handler.
            PageRotationEventHandler eventHandler = new PageRotationEventHandler();

            pdfDoc.AddEventHandler(PdfDocumentEvent.START_PAGE, eventHandler);
            Document doc = new Document(pdfDoc);

            doc.Add(HELLO_WORLD);

            eventHandler.SetRotation(LANDSCAPE);
            doc.Add(new AreaBreak());
            doc.Add(HELLO_WORLD);

            eventHandler.SetRotation(INVERTEDPORTRAIT);
            doc.Add(new AreaBreak());
            doc.Add(HELLO_WORLD);

            eventHandler.SetRotation(SEASCAPE);
            doc.Add(new AreaBreak());
            doc.Add(HELLO_WORLD);

            eventHandler.SetRotation(PORTRAIT);
            doc.Add(new AreaBreak());
            doc.Add(HELLO_WORLD);

            doc.Close();
        }
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));

            pdf.GetCatalog().SetPageLayout(PdfName.TwoColumnLeft);
            C07E01_EventHandlers.PageRotationEventHandler eventHandler = new PageRotationEventHandler();
            pdf.AddEventHandler(PdfDocumentEvent.START_PAGE, eventHandler);
            Document document = new Document(pdf, PageSize.A8);

            document.Add(new Paragraph("Dr. Jekyll"));
            eventHandler.SetRotation(INVERTEDPORTRAIT);
            document.Add(new AreaBreak());
            document.Add(new Paragraph("Mr. Hyde"));
            eventHandler.SetRotation(LANDSCAPE);
            document.Add(new AreaBreak());
            document.Add(new Paragraph("Dr. Jekyll"));
            eventHandler.SetRotation(SEASCAPE);
            document.Add(new AreaBreak());
            document.Add(new Paragraph("Mr. Hyde"));
            document.Close();
        }