Skip to content

m1ga/ti.print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Printer module for Titanium (Android)

Requirements

  • Titanium SDK 10.2.0

Example

const win = Ti.UI.createWindow({layout:"vertical"});
const btn1 = Ti.UI.createButton({title:"print image"});
const btn2 = Ti.UI.createButton({title:"print pdf"});
const btn3 = Ti.UI.createButton({title:"print html"});
const img = Ti.UI.createImageView({image:"/appicon.png"});

win.add([img, btn1,btn2,btn3]);
win.open();

const print = require("ti.print");

btn1.addEventListener("click", function() {
	// print image
	print.printImage({
		jobName: "image",
		image: img.toBlob()
	});
});

btn2.addEventListener("click", function() {
	// print pdf from app/assets/1.pdf
	print.printFile({
		jobName: "pdf",
		url: "/1.pdf"
	});
});

btn3.addEventListener("click", function() {
	// print html
	var localHTML = "<h1>external image</h1><img src='https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'/><br/><h2>local image</h2><img src='appicon.png'/>";
	print.printHTML({
		jobName: "test",
		html: localHTML
	});
});

Author