Get HTML Source of Specific DIV

Hi all,

I’m hoping to get some help on a subject here.

I have a web page, created dynamically. The page is different for each user and is populated based on database records and user input. When you visit the page directly (without first completing the steps beforehand to populate the data) all you get is a message telling you how to access the page.

I want to place PHP code on the final page (once it’s been dynamically generated) that copies the final HTML Source from a specific DIV (div id=“content”) into a variable that I can pass through a form as a hidden field to an external script that will allow me to create a PDF File using that content.

I know about file_get_contents but the problem with this function is it will simply read the URL of the final page and all that will give me is the message about how to access the full features of that page. I need to run this function AFTER the data has been populated and the page is completed. Then I will have the completed HTML Source of the “content” div and I can store it in a valuable to pass through to an external script via a form.

Any ideas?

Why can you not use the same method you use to get the content for the HTML with the PDF generation?

Have I understood your challenge:

a) User logs in, sees details on the page.

b) Sees a link, “produce a pdf of these details”.

c) Clicks it and downloads a PDF.

Is that the scenario?

or is c) really show a print friendly version?

Is the PDF file downloaded;

  • occassionally
  • sometimes
  • always, its mandatory

D: Are you trying to do this from your own website, or another?
I ask this because if it’s your own, you should already have access to that information while the page is being generated.

Huge apologies for taking so long to answer your questions. You may not even be watching this topic anymore but hopefully somebody else will see it and step in if necessary. I had to focus on some other work for a while so I’m only just revisiting this project.

I absolutely would do that if I knew how, hence the question. If there is a PHP Function that I can use to generate the PDF from the information already generated then please let me know what it is.

Almost correct! The user logs in, enters some details into a form, those details are uploaded to our database and they are given a unique ID. They are then taken to a page that dynamically generates a personalised astrology report based on the information they entered earlier. So, dependent on which Order ID is accessed, the information will ALWAYS be different. At the end of the report, I want a link that says “Download” which will take all of the information on the page (minus the page header/footer) and save it in a PDF.

Yes it is our website. We have access to all of the information - I can generate the personalised report and display it immediately to the user on screen, I just want to add a function to generate a PDF Download of the same output. I am sure there is an easy way to do it, I just don’t know what it is.

I realise it’s been a few months since I first asked this question so I’m hoping one of you is still watching or somebody else can step up if not. This is now at the top of my task list so I’m hoping to get it done asap!