skip to Main Content

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.

2

Answers


  1. 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 😀 :

    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.

    Login or Signup to reply.
  2. 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.

    enter image description here

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search