0

I was looking the HTML to PDF Conversion in android app

I have a problem to do the "it must be in package ".../java/android/print/" from solution number 1. How can I add the PdfConverter.java in android.print packages and the android studio recognise it ?

When I add it manually, fixing an PdfConverter.java and add it to the directory, the android studio do not recognise it and i got "Unresolved Reference : PdfConverter".

Is there another way, appropriate, to add the PdfConverter.java in the android.print package without getting the above error ?

Thank you in advance.

2 Answers2

2

Add the java class in such own-made package tree (right-click on java directory -> New -> Package -> name it "android", then do the same with "print", then add to this package the PdfConverter):

enter image description here

tomysek
  • 159
  • 1
  • 10
1

PdfConverter class is accessing PrintDocumentAdapter, from Android SDK's android.print package. You should made a package in project named android.print and I put PdfConverter class there and there would be no errors from lint in IDE.

Structure should be same as on this github repo https://github.com/blink22/react-native-html-to-pdf/tree/master/android

sela
  • 314
  • 1
  • 11
  • Of course I tried the solution you provide... didn't work. It must be in the android.print. – chaviaras michalis Mar 11 '20 at 17:22
  • If you do it then you take "Cannot access '': it is package-private in 'WriteResultCallback'" – chaviaras michalis Mar 11 '20 at 17:31
  • Yes I see, class is accessing PrintDocumentAdapter, from SDK's android.print package. Okay I have tried this, I've made a package in my project named android.print and I put this class there so there is no errors from lint in IDE. Same like on this github repo https://github.com/blink22/react-native-html-to-pdf/blob/master/android/src/main/java/android/print/PdfConverter.java – sela Mar 11 '20 at 17:41