SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Why can you not use the same method you use to get the content for the HTML with the PDF generation?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


    Quote Originally Posted by logic_earth View Post
    Why can you not use the same method you use to get the content for the HTML with the PDF generation?
    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.

    Quote Originally Posted by Cups View Post
    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
    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.

    Quote Originally Posted by StarLion View Post
    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.
    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!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •