Is it possible to make a PDF Template with many to many relationship?

In the create a pdf template function, the insert fields only support the default modules and one to one relationship. I am a noob and currently learning PHP now.
My situation: there is a many to many relationship between module A and B. A1 connects B1 and B2.
I am going to make a pdf for module A1, in the pdf I want to display the information from B1 and B2. Is it feasible?
In another module A2, it has a relationship with B1, B2 and B3, is it possible to dynamically alter the number of relationships in PDF Template?

Not out-of-the-box, no. Sorry.

There are a few modules that traverse relationships like that (Quotes, invoices, products) but they use custom code to do that, it doesn’t extend to other modules.

I made an add-on that would give you that option, it’s called PowerReplacer.

Hi pgr,
Thanks for your hard work!
I will try to make Quotes to be that module A.

Yes but it’s all hard coded, the only relationships that work are things like listing the products in a quote, or in a invoice. You won’t be able to get it to work with your own modules, unless you change a bit of PHP code.