2

I am looking to create a small app that allows a user to create a custom cover for a book. The client doesn't want to just be supplied with what the customer selected but a print ready 300dpi JPEG or PDF.

I know PHP can handle most of this. But the customisation seems to be a bit difficult to get right. I have tried using canvas to create the client side preview, which work ok enough.

Just to see if I'm wasting time trying to recreate the wheel, does anyone know if something like what I need exists already?

Basically it would be something kind of similiar to this but for creating print ready images.

Thanks!

4

2 に答える 2

1

If you're using Canvas for building the editor, for the best results, I'd recommend you re-render the customization on the server using whatever technology fits your need in PHP and not try to take the image they're looking at and make it work somehow by sending it to the server. The DPI will be wrong if you use Canvas in a standard way (it will be at the screen DPI).

For example, if they have the ability to place an image, then just note the coordinates and place the image in a web server created image at 300 DPI. Text, same thing, etc. Yes, it will be extra work, but it should be of higher quality and better consistency.

This would imply that there's a simple serialization format for the representation of the custom cover that is sent to the web server.

You might be able to use SVG, but you'll have to introduce a reliable SVG to PDF conversion and handle fonts. Maybe something like this? (I'm not sure that building an SVG editor would be easier than Canvas based).

于 2013-01-01T21:05:57.587 に答える
0

Starting from your "work ok enough preview", jsPDF will be able to generate a PDF right from the browser in a breez.

  • convert the canvas to a image/jpeg (toDataURL will be your best friend)
  • instanciate a jsPDF object, add the image
  • output the jsPDF object

Tricky details:

  • beware your screen displays stuff with 72dpi but print expect 300dpi. So you can up scale your canvas then draw the image within the pdf PDF
  • beware to Cross Origin Resources: if you are using images outside your domain, you are doomed (or you will need a proxy)
于 2013-06-26T22:39:32.497 に答える