1

I've a variable that contain HTML tags as string.

<table border="1">
    <tr>
        <td width="20">No.</td>
        <td>Name</td>
    </tr>
    <tr>
        <td>1.</td>
        <td>Someone</td>
    </tr>
</table>

Say, that variable name is $html_table. I want to sent that variable to TCPDF function, that's why I can't encode special characters because it needed for TCPDF to render correctly, my attempt was make a link to same page like this.

<a href="./index.php?printpdf=$html_table">Print PDF</a>

Then some code act as a handler.

if (isset($_GET['printpdf'])) {
    print_page($_GET['printpdf']);
}

As you know, it's not working at all. Even the contents from $html_table not show perfectly on address bar, is there any way to solve this?

Thanks in advance.

EDIT (SOLUTIONS)

Just using session variables like @Jay Bhatt said.

$_SESSION['printpdf'] = $html_table;

I point it to same page and have some handler

if (isset($_SESSION['printpdf'])) {
    print_pdf($_SESSION['printpdf']);
}

print_pdf() is function I made.

1 Answer 1

2

Try urlencode and urldecode functions. Also there is a limit to the characters you can send in url, if your html is long try using session variables. That way you won't have to worry about character encoding.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.