graph TD
Start[PDF Assembly Subagent Start] --> CollectData[Collect Module Data]
CollectData --> ContentCheck{Check Content Components}
ContentCheck --> |Module Text| ValidateText[Validate Text]
ContentCheck --> |Module Quiz| ValidateQuiz[Validate Quiz]
ContentCheck --> |Image URLs| ValidateImages[Validate Images]
ValidateText --> FormatContent[Format Content Layout]
ValidateQuiz --> FormatContent
ValidateImages --> FormatContent
FormatContent --> SelectFormat{Choose Format Type}
SelectFormat --> |HTML| CreateHTML[Generate HTML Layout]
SelectFormat --> |Markdown| CreateMarkdown[Generate Markdown Layout]
CreateHTML --> CompileDoc[Compile Document]
CreateMarkdown --> CompileDoc
CompileDoc --> ExternalPDF[External PDF Conversion]
ExternalPDF --> ValidatePDF{Validate PDF}
ValidatePDF --> |Success| SavePDF[Save Module PDF]
ValidatePDF --> |Failure| ErrorHandler[Handle Error]
ErrorHandler --> CollectData
SavePDF --> CheckModules{More Modules?}
CheckModules --> |Yes| CollectData
CheckModules --> |No| Complete[PDF Assembly Complete]