Path Construction or drawing operators aren't allowed inside a text objects-itextsharp pdf creation RRS feed

  • Question

  • Hello everyone!!!

    Here I am having trouble with drawing lines in pdf using itextsharp, above mentioned title is a exception which I am not able recognize what type of error is that, and I will attach the exception thrown image file for your reference, could anyone help me to fix it and make my day...

    thanks In advance,


    • Moved by CoolDadTx Tuesday, July 23, 2019 1:47 PM Third party product
    Tuesday, July 23, 2019 4:55 AM

All replies

  • Hiii Ante Meridian!!!

     Thank you so much for your kind attention and time for me..I tried what you mentioned, but it is still throwing another exception like unbalanced begin/end text operator, but I completely checked it is balanced one....I am attaching that image for your reference.

    Tuesday, July 23, 2019 5:31 AM
  • That message suggests you are calling EndText without calling BeginText first.

    When you added EndText to fix the first exception, did you also add a BeginText to match?

    cb.MoveTo(X, 842 - Y);
    cb.LineTo(X1, 842 - Y);
    chkLine = true;

    Tuesday, July 23, 2019 5:40 AM
  • hello Ante Meridian!!!

    I checked the same which u mentioned above, the exception(UNBALANCED BEGIN/END TEXT OPERATORS) is not arises in beginning stage of execution, it is throwing in between page creation like, in pageno:15, pageno:142.

    Tuesday, July 23, 2019 6:42 AM
  • Greetings again Revathi.

    I'm not sure you understood me.

    In order for the begin/end operators to be balanced they need to be in matching pairs, like opening and closing braces (curly brackets). So the sequence should be like this...

    // To text stuff here (like writing strings.
    // Do line drawing and other graphics stuff here.
    // Do more text stuff.
    // Do more graphics stuff.
    // And so on.

    What that error means it that it thinks you have done something like this...

    // Do text stuff.
    // Do graphics stuff.
    cb.EndText(); // Oops. This will give an exception, because we have called EndText twice without 
                  // calling BeginText in between.

    So if you fixed the original exception (from your first post) by adding a call to EndText, and did not add a BeginText afterwards, the next call to EndText will give an exception.


    Tuesday, July 23, 2019 6:52 AM
  • Hello Ante Meridian!!!!

    I will recheck again the code ….. thanks a lottt Meridian...

    Tuesday, July 23, 2019 7:04 AM
  • Please post questions related to third party products in their forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, July 23, 2019 1:47 PM
  • Thanks a lot for your kind support for me mr.Ante. my bugs are fixed earlier, sorry for delay response. I forget to add the end text in one catch() loop. that is my mistake
    Friday, July 26, 2019 10:01 AM