How to display image in jsPDF from input image upload - jspdf

I'm trying to work out how to upload in image using and display it in my PDF.
In the image below you can see the data that I get when passing it down to the PDF-component I've made.
Image data passed to jsPDF component
I've tried the doc.addImage(image, "png", ...) method, but I believe this is supposed to work with urls.
Any help is greatly appreciated!

Related

How to print with custom page in ruby on rails?

Can i print a lot of same barcode image (depends on total barcode) in rails?
Example total_barcode is 6, so i print 6 same barcode.
The image will fit with the layout.
If the size of paper only fit 4 image, and it will generate another page until there are 6 image
Its looks like
XX(page 1)
XX(page 1)
XX(page 2) the x is image
Thanks i hope you guys can understand what i'm trying to say 😭
This is possible.
I would suggest first creating the barcodes page as html, and then converting to pdf.
To create the barcodes on an html page, you have to use a barcode font (Google it), you will need to load the fonts into the page, and specify the barcode font for the barcode "text" in css. When you render text with a barcode font, it appears on the page as a barcode.
Next you need to convert the html to pdf. I suggest using the same url, but appending .pdf to the url instead of .html. You can look for libraries that convert from html to pdf.
Sorry I haven't provided much detail, this is a big project!

Merging Images To PDF in Swift

I want to create an app which asks the user to upload the pictures from the device camera and then merge those images as PDF using swift.
How can this be achieved?
I read your question and I have an idea for merging images to PDF.
Step 1: You need convert image to PDF. You can see the link below
https://github.com/SSA111/SwiftImageToPDFConverter/blob/master/NSData%2BImageToPDFConverter.swift
Step 2: Merge all files pdf

Prawn PDF Image Comes With Text

I am using prawn pdf in Rails 3.
I try to embed an image into my pdf file using
image "#{Rails.root}/app/assets/images/logo.png", :height => 30
The resulting PDF consists of the logo, which is good. However there is this line:
#<Prawn::Images::PNG:0x007ff7d1438f20>
printed below the logo.
There is nothing special with my code, I am just following this Railscast to set things up:
http://railscasts.com/episodes/153-pdfs-with-prawn
and added the image code.
May I ask if anyone faces the same problem and how to resolve it?
Thank you so much!

How to save cropped image of an image URL without saving the original image? (in Rails using Paperclip or other plug-ins)

Hi all
I have an app now showing photos from URL, not from my own database (file system).
For example, a photo from Facebook:
http://sphotos.ak.fbcdn.net/hphotos-ak-snc1/hs085.snc1/5041_98423808305_40796308305_1960517_6704612_n.jpg
I've added the crop function to get the cropping area (x,y,w,h) of the photo.
And now I'd like to save the cropped image from the URL (i.e. without downloading the original image to my database before cropping)
Is it even possible?
Or is there anyway to get the image into memory to process without saving it to database?
I've searched some questions here, but they all talk about how to save the crop of images which have been uploaded to the database by users.
Thank you very much in advance.
How do you imagine cropping works without access to the original image? The process would be like this:
Download the remote image to a /tmp as a temporary file (Tip: TempFile)
Crop the crap out of it
Save the cropped image with Paperclip to your DB
Remove the temporary file

Generate a thumbnail for the first page of a PDF within a rails App?

Is there anyway to generate a thumbnail image for the first page of an uploaded PDF file. I want to display this image along with the description (provided by the user) of the file.
The first answer from this question looks like it'll do what you want.
You can use an image processing library like ImageMagick to convert a PDF into an image.
Call out to the system with something like:
system("convert -size 150x150 /path/to/uploaded/document.pdf /path/to/thumbnail/file.png")

Resources