publiclab/mapknitter

Try to generate PDF map of all images client-side using jsPDF

Offen

#219 geöffnet am 25.04.2016

 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Ruby (203 Forks)auto 404
exportinghelp wanted

Repository-Metriken

Stars
 (274 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Now that we can export full-res images one by one, we should try to combine them into a PDF for download/printing. The syntax here looks pretty easy:

https://mrrio.github.io/jsPDF/

// You'll need to make your image into a Data URL
// Use http://dataurl.net/#dataurlmaker
var imgData = 'DATAURL';

var doc = new jsPDF();

doc.setFontSize(40);
doc.text(35, 25, "Map title");

doc.setFontSize(20);
doc.text(35, 75, "Map title");

doc.addImage(imgData, 'JPEG', 15, 40, 180, 180);

We could add a method similarly to our per-image download, since we already have calculated pixel sizes for image generation here: https://github.com/publiclab/mapknitter/blob/master/app/assets/javascripts/mapknitter/Map.js#L50-L90

Contributor Guide