mobileprint / android-print-sdk Goto Github PK
View Code? Open in Web Editor NEWAndroid library that simplifies printing with custom layouts, graphical preview, and more.
Android library that simplifies printing with custom layouts, graphical preview, and more.
webpage not available
Its not issue .But kind a question.
how to print text ?
for example remaining Ink/Toner
I have connected my brother printer to WIFI, and i want to get model name of the printer when ever i am connecting to same network through mobile application.
in my pdf file there are four pages of A4, but when I come to printing preview screen. it can't recognize other pages. Finally, when I print it out there is only first page come out.
Hello,
I have been trying to preset android print dialog options to user defined settings. But no matter what options i provide to setPrintDialogOptions, I get only ISO_A4 page size as default in dialog.
Following is the code i have been using:
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
PDFAsset pdfAsset = new PDFAsset(Uri.fromFile(mFile), false);
int pageTypeValue = Integer.parseInt(mSettingsPreferences.getString(Utility.SETTINGS_PDF_SIZE_TYPE, "4")); //User defined page size
PrintItem printItem = new PDFPrintItem(PrintItem.ScaleType.CENTER, pdfAsset);
PrintJobData printJobData = new PrintJobData(this, printItem);
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize(getSelectedMediaSize(pageTypeValue));
printJobData.setPrintDialogOptions(builder.build()); // No matter what i supply here
printJobData.setJobName("Print");
PrintUtil.setPrintJobData(printJobData);
PrintUtil.print(FinalPrescriptionActivity.this);
}
where getSelectedMediaSize(int value) returns MediaSize:
public PrintAttributes.MediaSize getSelectedMediaSize(int pageType) {
switch (pageType) {
case (0):
return PrintAttributes.MediaSize.ISO_A0;
case 1:
return PrintAttributes.MediaSize.ISO_A1;
case 2:
return PrintAttributes.MediaSize.ISO_A2;
case 3:
return PrintAttributes.MediaSize.ISO_A3;
case 4:
return PrintAttributes.MediaSize.ISO_A4;
case 5:
return PrintAttributes.MediaSize.ISO_A5;
case 6:
return PrintAttributes.MediaSize.ISO_A6;
case 7:
return PrintAttributes.MediaSize.ISO_A7;
case 8:
return PrintAttributes.MediaSize.ISO_A8;
case 9:
return PrintAttributes.MediaSize.NA_LETTER;
case 10:
return PrintAttributes.MediaSize.NA_INDEX_3X5;
}
return null;
}
Can someone please help me to set android print dialog options?
dos it has some way i can get the printer's paper state
The file stream I read during the printing was null, and the printing did not respond, and there was no error in the process
Here you set allowBackup
to true, any reason ? https://github.com/mobileprint/android-print-sdk/blob/master/mobileprintsdk/src/main/AndroidManifest.xml#L28
I want to set it to false in my application and I get :
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:14:9-36
is also present at [com.hp.mss:mobileprintsdk:v2.02.418] AndroidManifest.xml:36:18-44 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:12:5-79:19 to override.
If I use 'tools:replace="android:allowBackup"'
it's set to true and don't know why but my application is now called HP Print
instead of my title.
I use : com.hp.mss:mobileprintsdk:v2.02.418
.
Any ideas ? Thanks :)
implementation 'com.hp.mss:mobileprintsdk:v2.02.466@aar'
<data android:scheme="package" />
</intent-filter>
</receiver>
error: unknown element found.
Message{kind=ERROR, text=error: unknown element found., sources=[/Users/walaagomaa/android_projects/UPS/foodPageMerchant/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:27], original message=, tool name=Optional.of(AAPT)}
Can we bypass the dialog box using library and if we can't can you suggest any alternative ?
Thanks in advance
When I call this method " PrintUtil.print((Activity) context); "
It rise this exception
Unable to find explicit activity class {com.ebda3soft.myapp/adr}; have you declared this activity in your AndroidManifest.xml?
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
The deprecated leftShift used in mobileprintsdk/build.gradle
task javadoc(type: Javadoc) << {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task copyAarFile(type: Copy) {
def myDir = System.getProperty("user.dir")
def myFile = "mobileprintsdk.aar"
from("${myDir}/app/build/outputs/aar/")
into("${myDir}/")
include("mobileprintsdk.aar")
}
Update with doLast() as follows
task javadoc(type: Javadoc) {
doLast {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
}
task copyAarFile(type: Copy) {
doLast {
def myDir = System.getProperty("user.dir")
def myFile = "mobileprintsdk.aar"
from("${myDir}/app/build/outputs/aar/")
into("${myDir}/")
include("mobileprintsdk.aar")
}
}
Is it possible to print multiple images?
I try this :
ImageAsset imageAsset = new ImageAsset(getActivity(),
userPickedBitmap,
ImageAsset.MeasurementUnits.INCHES,
widthInches, heightInches);
ImageAsset imageAsset2 = new ImageAsset(getActivity(),
userPickedBitmap2,
ImageAsset.MeasurementUnits.INCHES,
widthInches, heightInches);
PrintItem printItem = new ImagePrintItem(imageAsset);
PrintItem printItem2 = new ImagePrintItem(imageAsset2);
PrintJobData printJobData = new PrintJobData(getActivity(), printItem);
printJobData.addPrintItem(printItem2);
PrintUtil.setPrintJobData(printJobData);
PrintUtil.print(getActivity());
And get :
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com., PID: 28385
java.lang.RuntimeException: Unable to start activity ComponentInfo{com./com.hp.mss.hpprint.activity.PrintPreview}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.hp.mss.hpprint.activity.PrintPreview.getSpinnerText(PrintPreview.java:159)
at com.hp.mss.hpprint.activity.PrintPreview.initializeSpinnerData(PrintPreview.java:127)
at com.hp.mss.hpprint.activity.PrintPreview.onCreate(PrintPreview.java:79)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
on android 5.0
java.lang.IllegalStateException: No default media size specified.
at android.print.PrinterCapabilitiesInfo$Builder.build(PrinterCapabilitiesInfo.java:521)
at com.android.printspooler.ui.PrintActivity$DestinationAdapter.createFakePdfPrinter(PrintActivity.java:1992)
at com.android.printspooler.ui.PrintActivity$DestinationAdapter.(PrintActivity.java:1715)
at com.android.printspooler.ui.PrintActivity.onPrinterRegistryReady(PrintActivity.java:301)
at com.android.printspooler.ui.PrintActivity.access$300(PrintActivity.java:107)
at com.android.printspooler.ui.PrintActivity$2.run(PrintActivity.java:261)
i wanna print job to printer list without
public static void createPrintJob(final Activity activity) {
PrintManager printManager = (PrintManager) activity.getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter adapter = new HPPrintDocumentAdapter(activity, printJobData, false);
final PrintJob androidPrintJob = printManager.print(printJobData.getJobName(), adapter, printJobData.getPrintDialogOptions());
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
EventMetricsCollector.postMetricsToHPServer(activity, EventMetricsCollector.PrintFlowEventTypes.ENTERED_PRINT_SDK);
PrintMetricsCollector collector = new PrintMetricsCollector(activity, androidPrintJob, appSpecificMetrics);
collector.start();
}
});
Hello,
I'm unable to reach the aar
file. Is there any alternative source?
Thank you!
Hello, seniors
Does this SDK support Bluetooth printing?
Dear..Brother
i wanna add printer and get printer list
i find no doc
thank you
Im trying to use this library in my project, but i found a issue when generating the APK.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/Request$Priority.class
I got this dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.volley:volley:1.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.squareup.picasso:picasso:2.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
compile 'com.uncopt:android.justified:1.0'
compile ('com.hp.mss:mobileprintsdk:v2.02.418')
}
There is a way to solve this?, i tried to exclude modules from volley, without success to solve this. Thank you
https://github.com/mobileprint/android-print-sdk/archive/master.zip
但是我的AndroidStudio没有编译成功,我接下来该怎么做呢
But my AndroidStudio did not compile successfully. What should I do next
如果发现这个issues 请您回复我,谢谢
If you find this issue, please reply to me, thank you
I want to directly click print, directly print without opening the preview page, is there a set switch
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.