The gemara says that the אנשי כנסת הגדולה authored Yechezel, Trei Asar, Daniel and Megillas Esther. Rashi explains that a Navi cannot record his prophesy in writing while in chutz la'aretz, therefore yechzkel, daniel and esther who were all in chutz la'aretz couldn't write their own sefer. Perhaps we could have offered an alternate explanation for Daniel since rashi writes in megilla 14a based on the gemara in megilla 3a that Daniel wasn't a Navi. It is logical to assume that if the sefer is going to be written by an individual, he must be a navi (otherwise the anshei k'neses hagedola would write it together).
Tosafos asks that Yirmiyahu managed to write his own sefer even though some of his prophesy was in Egypt and we don't find that he ever returned to eretz yisroel? From this Tosafos proves that prophesy can be recorded in chutz la'aretz.
The Noda B'yehuda (tinyana o.c. 106) was asked that Rashi in Yirmiyahu 44 seems to hold that Yirmiyahu was thrown out of mitzrayim and returned to eretz yisroel. The N.B. points out that Rashi doesn't explicitly write that Baruch and Yirmiyahu returned to eretz yisroel, rather rashi says "they returned from there because they were exiled by nevuchadnetzar". This means that they were thrown out of mitzrayim and returned to bavel as it says in seder o'lam. I found that the chasam sofer makes a reference to rashi in koheles (12:6) who writes explicitly as the N.B. suggests:
ששניהם (ברוך בן נריה וירמיהו) גלו לבבל, ופסקו מלימודם בעוני הדרך, תחילה גלו למצרים שהגלם יוחנן בן קרח, וכשהחריב נבוכדנצר את מצרים הגלם לבבל
Not surprising, but the N.B. read into rashi in Yirmiyahu exactly what rashi writes explicitly in Koheles.
This is also explicit in rashi in megilla 16b d.h. shekol:
ובמדרש שהיה (עזרא) לומד תורה מפי ברוך בן נריה בבבל, וברוך לא עלה מבבל ומת שם בתוך השנים הללו, ודאמרן לעיל ברוך נתנבא בשנת שתים לדריוש בבבל היה מתנבא ושולח ספרים לירושלים
Rashi seems to indicate that Baruch had prophesy in bavel and sent copies of it to Yerushalayim where it was able to be incorporated into the tanach.
Based on this, Tosafos question returns -we see Yirmiyahu was able to record his prophesy in writing from Bavel, so why couldn't Yechezkel and Esther have written their own seforim?
The Ya'avetz says simply that so long as the primary prophesy was coming from eretz yisroel, there could be some additions from chutz la'aretz. Therefore, Yirmiyahu who primarily prophesized in E.Y. was able to finish off his sefer by himself in bavel, but Yechezkel and Esther who prophesized primarily in chutz la'aretz couldn't record their own seforim.