Posts text and image to pdf in react - node.js

I'm trying to create a blog post website where anyone can post anything. And also any user can download any post in one click. So is it possible to implement a button for download whole specific post content except side menus and comment in react.

I assume you want to give the user the ability to download a blog post (react component) as pdf.
Check out this tutorial by Robin Wieruch
What you basically do is create a ref for your component and then convert it to a canvas with html2canvas npm package, then to image data.
The image data is added to a pdf with pdfjs npm package and downloaded.
See the link for details.

Related

How do I pull an image from a webpage in node js?

I'm currently trying to pull an image url from a website, and have that image url put in my code if that makes any sense.
Essentially, the request to the page goes through, and I need my code to grab an image on the page (the url of the image on the page), so it can send to a discord webhook.
What's the best way of doing this in node js? If this isn't enough information, please feel free to let me know and I will try my best to expand on this! Thanks.
Well, since you have only put your question and no code/situation, I'll just elaborate on how you can get it in general.
Page is Dynamic
What I mean by that is like, your page has content which you want to fetch and that content is loaded by JavaScript. Then you could try using Headless libraries like Puppeteer and Nightmare. Note that, all of these packages are kinda heavy, for example, Puppeteer installs Chromium (Not the Element, the Browser! If you don't know about it, read this) and Nightmare works with Electron (Again not the chemistry one, it is an NPM Package)
You can leverage the built-in functions in there to get the element which you want. However, you will need to do a lot of Inspect Element stuff to get the exact element you want!
Page is Static
What I mean by Static is that all of the stuff you need is in the default HTML yourself! So you won't need headless browsers for that. That's some heavy dependencies less for you.
So what you will want to do is, fetch the site using packages like Node-Fetch and Axios. I know it is possible to do it with the core Node.js Module called http but it is waaaaaay too much of a hassle to use and is not really that suggested.
On your request, you will get the Raw HTML of the site (looks kinda trash ngl). So now what you will need to do with this Raw HTML is to PARSE it to get your Image URL! You can use cheerio and JSDom to load your HTML and then parse the document to get the Image URL you want. Both are pretty awesome ngl.

Node.js and Vue.js, why Refresh make vue.js's store clear? And how can i use uploaded image in vue.js?

Title is my questions.
First. I'm making simple diary app with Node.js and Vue.js. Vue-router using history mode and in backend, using "connect-history-api-fallback" module. I think i did everything i can do, but when i run my app in local, refresh make vue.js's store clear. I googled but can't find same problem. Someone have any idea?
Second. I'm using Multer to upload. Upload is fine, i can see uploaded image. But i don't know how to show that uploaded image.
I mean in vue's template, what path will show uploaded image?
Image uploaded here "/simple-diary/backend/upload/profilePhoto/"
Vue.js component is here "/simple-diary/frontend/src/components/"
#samayo is right.One question per post.So of course when the page refresh the store is refreshed.So if you dont want that you can use plugin like vuex-persistedstate.Or if you want to keep the token and the user that is currently logged then when the user logged in,use localstorage to save the token and the user.Or cookies.Or session storage.You have many options

odoo base64 image not working on website for custom module

I am creating a custom module. Where in the backend user will be able to upload background image of a section. I have a binary field in the backend for that.
But for some reason the image is not showing. Here is the line of qweb code I am using -
<div id="comments1" class="parallax-section" t-att-style="'background-image: url(data:image/png;base64,'+res_company.website_logo_img+');'">
This loads the data in binary format incompatible way.
Following is the screenshot when I first load the webpage and image not shows-
Google developer Tools inspect element view
Following is the screenshot when I just take than line in editable mode and hit enter. The image shows nice and clear:
Google developer Tools inspect element view
Can anyone tell me what is the problem?

download images with exif informations from flickr

i use the FlickR REST-API to download some images.
For this, i call:
url_image="http://farm_id.staticflickr.com/server/id_secret_c.jpg;
the problem is that the downloaded file doesn't include exif data.
Is there a option to get the image with exif (For example date/time)?
Greetings
You can get a photo's EXIF info using this method flickr.photos.getExif
Retrieves a list of EXIF/TIFF/GPS tags for a given photo. The calling user must have permission to view the photo
Then just use the info you need.

how to reference an image in a dokument

I have an image that is stored within a document in the database.
the following url will open the image from the web client in the image control
/file/winter/$file/winter.jpg
but it doesn't work from the notes client.
How should I change the url to get it to work in the Notes client?
Your image is actually an attachment. You need the /xsp approach:
http(s)://[yourserver]/[application.nsf] /xsp/.ibmmodres/domino/OpenAttachment/ [application.nsf]/[UNID|/$File/[AttachmentName]?Open
Check the full details. Most likely you can skip the server and application part

Resources