done most of the pdf embedding functionality