Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18329] iOS: DocumentViewer.toImage() throws error

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2018-03-09T19:36:27.000+0000
Affected Version/sRelease 3.4.1, Release 3.5.0
Fix Version/sn/a
ComponentsiOS
Labelsdocument, qe-3.5.0, toimage
ReporterEric Wieber
AssigneeUnknown
Created2015-01-06T21:14:49.000+0000
Updated2018-03-09T19:36:27.000+0000

Description

Calling .toImage() on a DocumentViewer causes an error. The documentation indicates that this is a valid method. *Steps to reproduce issue*: 1. Build and launch app with below code and attached file 2. Click on Launch Doc 3. Wait 3 seconds 4. Notice the error below *Expected Results*: A blob containing the image of the document viewer is returned *Actual Results*: This error is thrown:
[ERROR] :  Script Error {
[ERROR] :      column = 48;
[ERROR] :      line = 36;
[ERROR] :      message = "undefined is not a function (evaluating 'docViewer.toImage()')";
[ERROR] :      sourceURL = "file:///Users/ewieber/Library/Developer/CoreSimulator/Devices/35905601-B2DA-40C8-B7AE-4FAE55D439CA/data/Containers/Bundle/Application/C464C7E6-CD8C-4E64-8F94-27146A23AFFB/docviewer.app/app.js";
[ERROR] :      stack = "file:///Users/ewieber/Library/Developer/CoreSimulator/Devices/35905601-B2DA-40C8-B7AE-4FAE55D439CA/data/Containers/Bundle/Application/C464C7E6-CD8C-4E64-8F94-27146A23AFFB/docviewer.app/app.js:36:48";
[ERROR] :  }
Use this code to repro:
var win = Ti.UI.createWindow();

// Use a NavigationWindow to create a navigation bar for the window
var navWin = Ti.UI.iOS.createNavigationWindow({
	window : win
});

var navButton = Titanium.UI.createButton({
	title : 'Launch'
});
win.RightNavButton = navButton;

var docButton = Titanium.UI.createButton({
	title : 'Launch Doc',
	height : 40,
	width : 200,
	top : 180
});
win.add(docButton);

// Create a document viewer to preview a PDF file
var docViewer = Ti.UI.iOS.createDocumentViewer();
// Opens the options menu and when the user clicks on 'Quick Look'
// the document viewer launches with an animated transition
navButton.addEventListener('click', function() {
	docViewer.show({
		view : navButton,
		animated : true
	});
});
// The document viewer immediately launches without an animation
docButton.addEventListener('click', function() {
	docViewer.url = 'test1.doc';
	docViewer.show();
	setTimeout(function(){
		Ti.Media.saveToPhotoGallery(docViewer.toImage());
	}, 2500);
});

navWin.open();

Attachments

FileDateSize
test1.doc2015-01-06T21:14:49.000+0000548864

Comments

  1. Hans Knöchel 2017-09-01

    Hey Eric, since I am currently working on other DocumentViewer-related tickets and found this one. I would mark it as invalid, since the doc-view is not a Ti.UI.View subclass and therefore does not have that API. It's rather a docs-issue where it states that it would have all the properties / methods that a Ti.UI.View has, but that's not the case. Anyway, we can expose this if you want - let me know!

JSON Source