I am using fancybox in my rails applicaiton , I want to display server side pdf response in fancybox ,but I am not sure how to do this .
I did the like this
I am reading pdf file data and sending pdf response from server , on view I need to display this pdf response in fancybox how to do this .
or any alternate way that I can show a pdf in fancybox instead download pdf from the server when requesting server.
###my_controller.rb
def show
#pdf_data = File.open(doc.image).read.force_encoding('BINARY')
format.js {}
end
From the above line it states that I am reading pdf file data(doc.image refers location of the pdf file) , Now I need to display this pdf content in fancy box ,so I did like the following on the view side
## show.js.erb
$("#pdfview").html("<%= #pdf_data %>")
$("#inline").trigger('click')
I applied fancybox() for #inline which is id of anchor tag.
Can anyone help me how to do this or any alternate that I can make pdf from server pdf response within the fancybox in jquery or javascript?
Related
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();
I am using laravel-dompdf to generate a pdf but to show images in that pdf I tried the route and controller approach but it's working for webpage but not for pdf. That's I am using the server path (/home/shashank/work/jobs/storage/app/{{$photo}}).
I want to know if it's safe or not.
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.
"Why" and "When" we get this code in JMeter response instead of the real/original page and how to get rid of it?
Script is running successfully but getting this in response & this appears randomly.
Code which i get in response against my request is as displayed in this screenshot:
In View Results Tree the default is showing the response as text file.
The default Text view shows all of the text contained in the response.
You want it to render as Html so choose in drop down of component as HTML or HTML (download resources) and JMeter will render it similar to browser
If the HTML (download resources) view option is selected, the renderer may download images, style-sheets, etc.
Can we able to generate a pdf from HTML page , where we are using two css files Style.css and bootstrap.css. Is it is feasible to render html page to pdf as it is displayed in the UI.
Yes, we can generate a pdf from HTML page.You can generate your html page using phantom.js which provides a Javascript API to generate .pdf ,.png,.jpg etc of any static HTML page.Static page means single .html page where resources also included.The steps are as follow:
Download phantomjs-2.0.0-windows.zip from http://phantomjs.org/download.html.
Go to the C:\Users\USER\Downloads\phantomjs-2.0.0-windows\phantomjs-2.0.0-windows\bin ,{C:\ where library downloaded}
3.open a terminal and jump to C:\Users\USER\Downloads\phantomjs-2.0.0-windows\phantomjs-2.0.0-windows\bin>
type a command on terminal: phantomjs {refer rasterize.js} "your static html page url" {target dirctory/file.extension}
for example>C:\Users\USER\Downloads\phantomjs-2.0.0-windows\phantomjs-2.0.0-windows\bin> phantomjs ../examples/rasterize.js "http://phantomjs.org/download.html" abc.pdf