|
@@ -8,10 +8,14 @@ import android.graphics.Bitmap
|
|
import android.graphics.RectF
|
|
import android.graphics.RectF
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import com.kdanmobile.kmpdfkit.annotation.bean.*
|
|
import com.kdanmobile.kmpdfkit.annotation.bean.*
|
|
|
|
+import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
|
|
import com.kdanmobile.kmpdfkit.globaldata.Config
|
|
import com.kdanmobile.kmpdfkit.globaldata.Config
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.*
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.*
|
|
|
|
+import com.kdanmobile.reader.screen.data.ShapeAttribute
|
|
|
|
+import com.kdanmobile.reader.screen.data.StampAttribute
|
|
|
|
+import com.kdanmobile.reader.screen.data.TextBoxAttribute
|
|
import com.kdanmobile.reader.screen.handler.*
|
|
import com.kdanmobile.reader.screen.handler.*
|
|
|
|
|
|
class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMsg: String) : ViewModel() {
|
|
class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMsg: String) : ViewModel() {
|
|
@@ -206,6 +210,35 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ fun setTextBoxAttribute(attr: TextBoxAttribute) {
|
|
|
|
+
|
|
|
|
+ val kmpdfFreetextAnnotationBean = KMPDFFreetextAnnotationBean("", attr.textColor, attr.textSize, 255, "Courier", attr.isBold, attr.isItalic)
|
|
|
|
+ kmpdfFactory?.setAnnotationAttribute(kmpdfFreetextAnnotationBean)
|
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.FREETEXT)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun setStampAttribute(attr: StampAttribute) {
|
|
|
|
+
|
|
|
|
+ val kmpdfStampAnnotationBean = when (attr.isStandardStamp()) {
|
|
|
|
+ true -> KMPDFStampAnnotationBean("", KMPDFStampAnnotationBean.StampType.STANDARD, KMPDFStampAnnotationBean.StandardStamp(attr.resId))
|
|
|
|
+ false -> KMPDFStampAnnotationBean("", KMPDFStampAnnotationBean.StampType.TEXT, KMPDFStampAnnotationBean.TextStamp(attr.rect, attr.config))
|
|
|
|
+ }
|
|
|
|
+ kmpdfFactory?.setAnnotationAttribute(kmpdfStampAnnotationBean)
|
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.STAMP)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun setShapeAttribute(attr: ShapeAttribute) {
|
|
|
|
+
|
|
|
|
+ val kmpdfShapeAnnotationBean = when (attr.shapeType) {
|
|
|
|
+ AnnotConfig.ShapeAnnotationType.LINE -> KMPDFLineAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha)
|
|
|
|
+ AnnotConfig.ShapeAnnotationType.ARROW -> KMPDFArrowAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha)
|
|
|
|
+ AnnotConfig.ShapeAnnotationType.CIRCLE -> KMPDFCircleAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha, attr.fillColor, attr.fillAlpha)
|
|
|
|
+ AnnotConfig.ShapeAnnotationType.SQUARE -> KMPDFSquareAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha, attr.fillColor, attr.fillAlpha)
|
|
|
|
+ }
|
|
|
|
+ kmpdfFactory?.setAnnotationAttribute(kmpdfShapeAnnotationBean)
|
|
|
|
+ kmpdfFactory?.setAnnotationEditMode(kmpdfShapeAnnotationBean.type)
|
|
|
|
+ }
|
|
|
|
+
|
|
val pdfInfoHandler = object : PdfInfoHandler {
|
|
val pdfInfoHandler = object : PdfInfoHandler {
|
|
override fun getOpenPdfFilename(): String {
|
|
override fun getOpenPdfFilename(): String {
|
|
return kmpdfFactory?.fileName ?: ""
|
|
return kmpdfFactory?.fileName ?: ""
|