如何在pspdf flutter中向PDF添加图像注释?

huangapple go评论80阅读模式
英文:

How to add image annotation to pdf in pspdf flutter?

问题

我想要添加图像到PDF的代码。我在我的Flutter应用中使用pspdfkit。

我看到了pspdfkit flutter的官方文档。在那里,他们解释了如何将图像注释添加到pspdfkit web,但没有说明如何在pspdfkit flutter中添加图像注释。我需要代码或任何指南,帮助我在pspdfkit flutter中添加图像注释。

英文:

I want the code that adds an image to pdf. I am using pspdfkit in my flutter app.

I saw the official documentation of pspdfkit flutter. There they have explained how to add image annotation to pspdfkit web, but not pspdfkit flutter. I need code or any guide that would help me adding image annotation to pspdfkit flutter.

答案1

得分: 1

我尝试在Flutter中以交互方式(缩放/拖放/旋转)将签名图像插入到PDF中。以下是一些建议:

  • PSPDFKit 不是免费且不开源。因此,如果您正在开发商业应用程序,必须注意这一点。对于我来说,我的公司和老板不希望依赖于付费库,所以我不能使用这个包。
  • 在使用开源库的情况下:目前(截止到 2023年5月6日),没有真正的Flutter/Dart包允许您将图像添加到PDF中。因此,您必须在原生Kotlin + Swift中处理它。

这将需要大量的努力,您可以像我一样挑战自己:D:

注1:这是一项困难的任务,因为如果要正确地将图像插入到PDF中,您需要计算PDF中图像的坐标。请记住,PDF的坐标从底部左侧开始,而手机的坐标从顶部左侧开始。而PDF的度量单位是点(POINTS),而其他度量单位可以是像素或DIP。

注2:您可以使用MethodChannel将整个Flutter屏幕完全转换为本地代码,或者您可以使用Platform View将Flutter与本地结合使用(这样可以更容易在Flutter和本地之间进行通信,但更难创建)。我正在使用后一种选项。

也许这不是您想要的答案,但也许将来有些人可能会遇到同样的问题,所以我仍然在这里回答,也许在某一天会有所帮助。

英文:

I tried to insert signature image to PDF in Flutter in an interactive way (scale/drag & drop/rotate). Here are some advices for you:

  • PSPDFKit is NOT free and NOT open-source. Therefore if you are making an commercial app, you must notice about this. For me, my company & boss doesn't want to depend on a paid library, so I cannot use this package.
  • In case of open-source library: Currently (at this time 5/6/2023), there's no TRUE Flutter/Dart package that allow you to add image to a PDF. Therefore, you must handle it in native Kotlin + Swift.

This will take A LOT of effort, you could challenge yourself, like I did 如何在pspdf flutter中向PDF添加图像注释? :

Note 1: This is a hard task because if you want to insert an image to PDF correctly, you need to calculate COORDINATES of image in PDF. Keep in mind, coordinates of PDF is from bottom-left whereas phone is top-left. And the measurement of PDF is POINTS, whereas other can be pixels or DIP.

Note 2: You can use MethodChannel to completely change your Flutter entire screen to native code, or you can use Platform View to combine Flutter + native (that could easier to communicate between Flutter + native but harder to create). I'm using the latter option.


Well this maybe not a answer that you want, but maybe in future some guys could meet the same problem so I still answer here, maybe helpful some days.

答案2

得分: 0

方法通常在任何应用程序/ PDF 中都是相同的,要放置在页面上的对象通常是通过叠加来追加的,因此 PDF 或图像都不重要,您可能会发现某些应用程序将其称为水印。

如何在pspdf flutter中向PDF添加图像注释?

至于代码,我只能指向相关示例,可以在 GitHub 上找到,例如 https://github.com/PSPDFKit/pspdfkit-android-catalog/blob/32476b0ce1dd482c740786217582135b646310e4/app/src/main/java/com/pspdfkit/catalog/examples/java/activities/AnnotationWithAlphaCreationActivity.java

英文:

The method is in general the same in any application/pdf the object to be placed over a page is normally appended by over stamping, thus PDF or image it should not matter you may find some applications call it watermark.

如何在pspdf flutter中向PDF添加图像注释?

As for code I cannot help except to point to related examples can be found in github such as https://github.com/PSPDFKit/pspdfkit-android-catalog/blob/32476b0ce1dd482c740786217582135b646310e4/app/src/main/java/com/pspdfkit/catalog/examples/java/activities/AnnotationWithAlphaCreationActivity.java

huangapple
  • 本文由 发表于 2023年6月5日 14:47:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404059.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定