Easily use markdown2pdf.ai to convert markdown (.md) to high-quality and impactful PDF in your Python-based agentic workflows using our Python software development kit (SDK).
on_payment_request
function is called when payment is required, allowing you to handle the payment process in your application. There are several ways of handling payments automatically, such as fewsats.com or albyhub or using a Lightning wallet that supports automatic payments. In the example above, we simply print the payment details and wait for you to confirm payment manually. You can simply copy and paste the lightning invoice into your lightning wallet to pay.
class MarkdownPDF
constructor
offer
object containing details about the payment, such as amount, currency, description, and the Lightning invoice. You can implement your own logic to handle payments here. This parameter is required because the service uses the L402 protocol, which requires a payment to be made before generating the PDF.None
or omitted.convert
True
, the method will return the PDF content as a byte string. If set to False
, it will save the PDF to the specified download_path
or return the path if no path is provided.For example: