I have a Laravel 6 app and am using laravel-domPDF elsewhere in my app just fine. However, I want to create a PDF from a section of the view page. I have the HTML I need rendered-out stored in a variable, but the code to render out the HTML is PHP and I can't execute PHP from a button on the view page without a reload of the page, which loses the variable.
I have a controller just to render out the HTML, but can't find a way to pass that large HTML string to the controller from the view. I can't pass it via a route as it sends the HTML as a parameter attached to the URL and apart from looking terrible, it doesn't work.
How can I get a section of HTML in my view into the following PHP to render the PDF using a button on my view?
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML($table_html_pdf);
return $pdf->stream();
Related
I have used dompdf in my laravel application and I'm calling the pdf generate function from the same form submit button and both are working fine. The only issue I'm facing right now is on my generated pdf file every hard refresh/reload, form data is submitting again to the database. Is there any possible way that i can prevent that reload or form submit?
I tried with this below Jquery but that completly prevent my form by clicking the button also. I just want that form not to submit again on pdf file reload.
$("#orderForm").submit(function(e) {
e.preventDefault();
});
Within an article in Joomla, I have the following code:
(loadposition file_download)
This line of code loads more code, but I cannot access it from the Articles page. How do I access the loadposition code?
On the web you are always striving to separate content from display. Here you are just setting up the display so that when the page renders items in the file_download position will render. That is the html for whatever is in file_download will be generated dynamically when the user looks at the page in the browser. In the editor you are just creating html. If you save the article and view it in the rendered form (i.e. in the Joomla frontend) you will see that loadposition will do its work of rendering whatever it is that file_download asks it to render. That is loadposition is a way to dynamically include content (which might include text, javascript, whatever) into an article.
I'm having problem with generating pdf using dompdf.
I'm using following code to generate the pdf:
$pdf = PDF::loadView('myview', compact('data', 'data2'));
return $pdf->stream($file_name . '.pdf');
It's generating pdf but the problem is datatable. Apart from this data showing on the page there is a datatable in the view which has serverside ajax call to generate datatable.
Dompdf is not generating thos data when it creats pdf file.
Any help would appreciated.
Thank you,
Dompdf does not support javascript while rendering, so it will never execute that ajax call to populate datatable.
From dompdf wiki page
inline PDF Javascript support (with scripts compatible with the PDF Documents API)
That means that javascript will be embedded in the PDF, and that you can use JavaScript for Acrobat API Reference. You can also look into javacript for acrobat.
However,some of the PDF viewers might not support all of the API.
So, in your case, you need to create a new view that renders the table without using the javascript.
hi im working into a full ajax enviroment page, but i have the need to upload a file into my app, i used an iframe to "display" my form to upload (since i cant upload a file using pure ajax enviroment) but when i try to return to my ajax enviroment i cant get the view that i need, i keep locked "inside" the iframe, any ideas how to get out of the iframe and continue my app processing?
or an alternative to do this using jquery?
thanks a lot Mitzato
edit
im using rails 3
some html5
and ajax
You could update a div in the parent of the iframe with the response you get in the iframe using the top.document, like:
$("#myid", top.document);
You would need to include jquery.js in the iframe...
Well the final solution was to create a parent div and in another view create the iframe, then insert my form into my iframe, and finally I add and script in the botton that deletes the div where the iframe is contained that returns me to my ajax environment.
Im unsure of how to approach this, should I have the html to be loaded hidden or load it from somewhere? I want to load a form in one page, and dynamic content on other pages.
The form can be saved to mongo db, and when the page loads should load the data into that form from mongo db.
Where does the html live for all the pages? I want to have a clean html5 document with lets say a content div. all content goes into that block.
Server running Django
Im want to use backbone.js for the app
any help would be appreciated
The initial page should include the basic layout of the application (header, content, sidebar, different placeholder for your views, etc.)
Then you load the application (usually with a controller) and render the different view that will replace the placeholders you had in your layout.
To render the views, I suggest to use a templating engine. With backbone.js there is already underscore.js on the page, so you can use the templating engine included (http://documentcloud.github.com/underscore/#template). You then have to load the template on the page. The easiest way is to create include a script element on the page with your template inside:
<script type="text/template" name="template1">
your template here...
</script>
And you can load it using this:
var template = _.template( jQuery("script[name=template1]").text() )
and execute with your data
var html = template(model)
You build your page with different backbone views using different template.
I hope that help!