0

I use this code as taken from the example of iText7 header. But it is for rotation and I did not find any paragraph adding. Please, help

protected internal class PageEventHandler : IEventHandler
{
    //?????????????????????????????????????????????????????
    // what to write insted?
    protected internal PdfNumber Header = PrintPdf.PORTRAIT;
    //------------------------------------------------------

    public virtual void HandleEvent(Event @event)
    {
        PdfDocumentEvent docEvent = (PdfDocumentEvent)@event;
        string strFirstHeader = "ךוניחה דרשמ" + "\n";
        iText.Layout.Element.Paragraph pargraphFirstHeader = new iText.Layout.Element.Paragraph(strFirstHeader);
        pargraphFirstHeader.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
        var font = iText.Kernel.Font.PdfFontFactory.CreateFont(@"D:\Inetpub\wwwroot\Prog\Font\David.TTF", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED);
        pargraphFirstHeader.SetFont(font);
        pargraphFirstHeader.SetBold();
        pargraphFirstHeader.SetFontSize(14);
        pargraphFirstHeader.SetFontColor(iText.Kernel.Colors.ColorConstants.BLUE);
        pargraphFirstHeader.SetBaseDirection(iText.Layout.Properties.BaseDirection.RIGHT_TO_LEFT);

        //???????????????????????????????????????????????????????????????????????????????
        //Eventually this does not work
        docEvent.GetPage().Put(pargraphFirstHeader, pargraphFirstHeader.SetFont(font));
        //-------------------------------------------------------------------------------


        //document.Add(pargraphFirstHeader);

        string strsecondHeader = "עדימ תוכרעמו היגולונכט בושקית להנימ" + "\n" + "ינוכית לע יגולונכט ךוניח חוקיפ" + "\n\n";
        iText.Layout.Element.Paragraph pargraphsecondHeader = new iText.Layout.Element.Paragraph(strsecondHeader);
        pargraphsecondHeader.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
        pargraphsecondHeader.SetFont(font);
        pargraphsecondHeader.SetBold();
        pargraphsecondHeader.SetFontSize(12);
        pargraphsecondHeader.SetFontColor(iText.Kernel.Colors.ColorConstants.BLUE);
        pargraphsecondHeader.SetBaseDirection(iText.Layout.Properties.BaseDirection.RIGHT_TO_LEFT);
        iText.Layout.Borders.Border SolidBorderBlue2 = new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.BLUE, 2);
        pargraphsecondHeader.SetBorderBottom(SolidBorderBlue2);


        //??????????????????????????????????????????????????????????
       //How to modify for adding the paragraph?
        docEvent.GetPage().Put(PdfName.DisplayDocTitle, this.Header);
       //------------------------------------------------------------

Please, How to correct this code for paragraph as a header? I write the places with the problem. with //????????????????? and //---------------------

Please, Help.

Avi
  • 1
  • 3
  • Hope this earlier question its responses help you. https://stackoverflow.com/questions/46044511/how-to-place-paragraphs-in-specific-place-using-itextsharp – Sathish Guru V Feb 09 '20 at 09:55
  • Sorry Hamed, it does not help. I want to use iText7 EVENT for skipping to the next page or the first page. how to write the proper lines mention above. – Avi Feb 09 '20 at 11:55
  • your problem is not clear at all ?! can you explain what do you want to do ?! – Hamed Moghadasi Feb 09 '20 at 18:09
  • I want to add the paragraph in the event to the header in every page – Avi Feb 10 '20 at 05:10

0 Answers0