In one of my views I would like to display a PDF, which is accesible via URL. This should be done without opening an extra tab in the browser, and without downloading the PDF (to view it outside the browser). It should be visible embedded within the Ember application.
What I have in mind is:
Use the URL to get the PDF and make it accessible to the ember application.
Use a special "PDF view" to display the PDF.
Is this possible? What options do I have to display an embedded PDF in an Ember application?
Displaying a PDF is not really related to ember, because to view a PDF you need a PDF plugin installed in your browser (which is mostly installed by default depending by the browser).
That said, a possible solution I could imagine could be to create a custom ember view with the tagName iframe on which you set the src attribute to the link referring to the PDF.
Example:
App.PDFView = Ember.View.extend({
tagName: 'iframe',
attributeBindings: ['src', 'width', 'height', 'frameborder'],
src: 'pdffile.pdf',
width: 800,
height: 600,
frameborder: 0
});
I've also used width, height and frameborder only for convenience so you can control some of the iframe's attributes easily from within ember. Here a working demo.
You can also go with something more elaborated and use a js lib like http://pdfobject.com/ which you then initialize in your view's didInsertElement hook:
App.PDFView = Ember.View.extend({
src: 'pdffile.pdf',
width: 800,
height: 600,
didInsertElement: function() {
new PDFObject({
url: this.get('src'),
width: this.get('width'),
height: this.get('height')}
).embed(this.get('elementId'));
}
});
(haven't tested the latter, but you get the point)
And then use this App.PDFView like a normal ember view in your templates.
{{view App.PDFView}}
Or your can set the src, width & height directly from within your template like
{{view App.PDFView src="pdffile.pdf" width="600" height="800"}}
Hope it helps.
You can certainly leverage the Ember PDFJS Addon by doing:
ember install ember-pdfjs
The README on GitHub describes the installation and use cases.
In short, the addon provides your Ember project with a component, pdf-document, which you can use in your HTMLBars template like so:
{{pdf-document src=[model.src]}}
... there are other permutations of what src can be (including a string file path, resource URI, or Uint8Array buffer).
If you don't see a feature that you need, please suggest in the Issues.
Related
I'm trying to display a dynamic image with v-bind and it s not working
in template tag:
<img v-bind:src="test" />
in script tag :
data() {
return {
items: [],
imagesref: "",
test: '~/assets/captures/ref_01_03_2022_17_05_21/#DHRD-52484/user language check dates in different language/1.png'
};
I tired to use the test path on an img tag to check if there's something wrong with the path but it worked fine.
how can i fix this
v-bind:src works as expected. The problem is your path makes no sense in the context of your web page.
To translate a project path into a web path, use vue-loader. Namely:
test: require('./relative/path/to/image.png')
Or you can make use of the existing transform rules.
Note: This might vary based on configuration, but in a standard Vue project, replacing ~/assets with #/assets should fix the problem, without needing require().
So my custom loader is not loading instantly only like a split second then it loads here is my site, my goals is to my custom components load. PS when i change ssr to false it works
here is my site: https://micahkwaka.dev
export default {
loading: '~/components/LoadingBar.vue',
loadingIndicator: false,
ssr: true,
pageTransition: {
name: 'my-page',
mode: 'out-in'
},
// Target (https://go.nuxtjs.dev/config-target)
target: 'static',
}
EDIT: This loader is when you have an SPA, to wait for it to load before showing the content. Since you're using Nuxt as an universal app (ssr + client), you will have the static content first (before the JS kicks in, and therefore your animation). So, you could make one with static SVG/CSS but the backed-in JS loader is not the solution here.
The best way would be to disable the JS to test the final result. Still, I'm pretty sure that Google will give you a better rating if you do not have any loader. You could maybe add it to your page transitions tho.
For the animation itself, start with it, then setTimeout the removal of it after 500ms or alike. Plenty ways of doing it. But you will need to have it on the initial render of your page (before the JS hydration).
Why do you set the loadingIndicator to false if you want it ?
If you want a custom one, provide a path to key as explained in the documentation: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-loading-indicator/
I am trying to add Font Awesome support to Ckeditor5-inline and it just removes the "i" tags from HTML when I go in Edit mode.
First download font awesome if you haven't already then
1. Extract the downloaded file (fontawesome.zip) Copy the "fontawesome"
2. folder to "ckeditor/plugins/" folder Open the file
3. "ckeditor/config.js"
configure that like this and clear your browser's cache
config.extraPlugins = 'fontawesome';
config.contentsCss = 'path/to/your/font-awesome.css';
config.allowedContent = true;
In your HTML's section add this code:
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
after that you can Use toolbargroupname: "FontAwesome" in your toolbar like this
config.toolbar = [
{ name: 'insert', items: [ 'FontAwesome', 'Source' ] }
];
as you commented your are using Django Integration in Django CMS
Django CMS enables adding text-based content to a site using CKEditor which is integrated through the module called djangocms_text_ckeditor. In that module is a static folder and settings.py file, which are setup in a manner that enables fully customizing CKEditor.
you can check here for Django Integration
I use prerender-spa-plugin in vue.js app for rendering html
but it can't render dynamic data.
when prerender-spa-plugin complete rendering
created html file only contains some html code not showing any dynamic data
Method
Mounted
prerender-spa-plugin Configuration
Adding the headless option solve the problem for me:
renderer: new Renderer({
injectProperty: '__PRERENDER_INJECTED',
renderAfterTime: 5000,
// Other puppeteer options.
// (See here: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions)
headless: false // Display the browser window when rendering. Useful for debugging.
})
Is there an option in DOJO where files can be uploaded by Drag and Drop from desktop to the browser?
No I dont believe so. As outlined here and here its not really possible to do without using a plugin.
Old post, but still one of those posts being found by google easily. For those interested how to do this:
Have a look at this SO answer
Dojo overview of how to use its Uploader (styled as a button)
Use addDropTarget to link a dropArea for that uploader (for HTML5-enabled browsers -- see also first link))
To make the drop target visibly react to drag events, I had to connect directly to browser events like ondragenter or ondragleave (see code snippet below)
createUploader: function() {
// ... define uploader and droptarget
d_on(this.dropArea, "dragover", d_lang.hitch(this, this.dropAreaOver));
d_on(this.dropArea, "dragleave", d_lang.hitch(this, this.dropAreaLeave));
d_on(this.dropArea, "drop", d_lang.hitch(this, this.dropAreaLeave));
}
dropAreaOver: function(evt) {
evt.preventDefault();
domClass.add(this.dropArea, "dropAreaOver");
},
dropAreaLeave: function(evt) {
evt.preventDefault();
domClass.remove(this.dropArea, "dropAreaOver");
}