Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): move WebView contants into correct file #14186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Mar 3, 2025

while adding constants to the #14172 PR I found out that the current contants for createPDF are in the wrong file. This PR will move them so you can use them with Ti.UI.WebView.PDF_PAGE_DIN_A5

// output all values
console.log(Ti.UI.WebView.PDF_PAGE_AUTO);
console.log(Ti.UI.WebView.PDF_PAGE_DIN_A5);
console.log(Ti.UI.WebView.PDF_PAGE_DIN_A4);
console.log(Ti.UI.WebView.PDF_PAGE_DIN_A3);
console.log(Ti.UI.WebView.PDF_PAGE_DIN_A2);
console.log(Ti.UI.WebView.PDF_PAGE_DIN_A1);

const window = Ti.UI.createWindow();
const www = Ti.UI.createWebView({url: "https://tidev.io"});
const btn = Ti.UI.createButton({title: "create pdf", top: 10});
window.add([www, btn]);
window.open();

btn.addEventListener("click", function() {
	if (OS_ANDROID) {
		www.createPDF({
			pageSize: Ti.UI.WebView.PDF_PAGE_DIN_A4,
			success: function(e) {

				winImageFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "test.pdf");
				winImageFile.write(e.data);

				var igIntent = Ti.Android.createIntent({
					action: Ti.Android.ACTION_SEND,
					type: "application/pdf"
				});
				igIntent.putExtraUri(Titanium.Android.EXTRA_STREAM,winImageFile.nativePath);
				Ti.Android.currentActivity.startActivity(igIntent);


			}
		})
	}
})

Test
Run the code, wait until the page is loaded and press "create pdf". It should show a share dialog and when you view the PDF it size should be A4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant