我正在开发一个应用程序使用德尔福XE8,我需要打印一份报告。
这个报告有更多的页面,所以我不能创建一个简单的图像并分享它。
我们的想法是使用FMX.Printer。
但TPrintDialog只能在视窗系统上运行,不能在安卓系统上运行。如何从云打印列表中选择打印机?
你有什么意见建议?
谢谢
发布于 2015-09-11 23:38:10
如果设备上安装了官方Google Cloud Print应用程序,那么您应该能够按照以下问题的答案中所述的意图访问它:Print Intent for Google Cloud Print App
Intent printIntent = new Intent(Intent.ACTION_SEND);
printIntent.setType("text/html");
printIntent.putExtra(Intent.EXTRA_TITLE, "some cool title for your document");
printIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(printIntent);我猜Android会显示一个对话框,里面有可用的选项,包括Cloud printers。
谷歌云打印文档:https://developers.google.com/cloud-print/docs/android
用于检索打印机列表的接口:https://developers.google.com/cloud-print/docs/proxyinterfaces#list
发布于 2015-11-02 11:13:37
将此代码放入Delphi中应如下所示:
uses
...
FMX.Platform.Android,
Androidapi.Helpers,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.Embarcadero,
...
var
printIntent: JIntent;
begin
printIntent := TJIntent.Create;
printIntent.setAction(TJIntent.JavaClass.ACTION_SEND);
printIntent.setType(StringToJString('text/html'));
printIntent.putExtra(TJIntent.JavaClass.EXTRA_TITLE, StringToJString('Testing print from Android'));
printIntent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, StringToJString(uri));
if MainActivity.getPackageManager.queryIntentActivities(printIntent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then //Checks if there is at least one application capable of receiving the intent.
MainActivity.startActivity(printIntent) //Calls startActivity() to send the intent to the system.
else
ShowMessage('Receiver not found');基于来自http://docwiki.embarcadero.com/CodeExamples/Seattle/en/FMX.Android_Intents_Sample的示例代码
https://stackoverflow.com/questions/32517598
复制相似问题