Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Mar 02, 2021 8:37 am

Hi

I have a weird bug when adding annotations with Spire.PDF for Android V3.1.0.
Basically, if I create a new PDF and add an annotation, it works.
But if I create a new PDF, save it, read it back and add the annotation, it doesn't work.

You can find my whole Android Studio project as an attachment, but this is my code:

Code: Select all
package com.example.spiretest;

import android.graphics.Color;
import android.graphics.RectF;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.spire.license.LicenseProvider;
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.annotations.PdfPopupAnnotation;
import com.spire.pdf.annotations.PdfPopupIcon;
import com.spire.pdf.graphics.PdfFont;
import com.spire.pdf.graphics.PdfFontFamily;
import com.spire.pdf.graphics.PdfPens;
import com.spire.pdf.graphics.PdfRGBColor;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    private static final String licenseKey = "Insert the license key here";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        testPdf();
    }

    private void testPdf(){
        String createPdfPath = new File(getExternalFilesDir(null), "createPdf-Test.pdf").getAbsolutePath();
        String createAppendPdfPath1 = new File(getExternalFilesDir(null), "createAppendPdf-Test1.pdf").getAbsolutePath();
        String createAppendPdfPath2 = new File(getExternalFilesDir(null), "createAppendPdf-Test2.pdf").getAbsolutePath();

        LicenseProvider.setLicenseKey(licenseKey);

        createPdf(createPdfPath);
        createAppendPdf(createAppendPdfPath1, createAppendPdfPath2);
    }

    /**
     * This method works and creates a PDF with an annotation.
     * @param path Where to save the PDF.
     */
    private void createPdf(String path){
        try {
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.appendPage();

            addAnnotation(page);

            doc.saveToFile(path);
        } catch (Exception ex){
            ex.printStackTrace();
        }
    }

    /**
     * This method creates an empty PDF.
     * Then it reads the PDF and adds an annotation.
     * However, the resulting PDF only has the text, the annotation is missing.
     * @param path Where to save the empty PDF.
     * @param output Where to save the PDF which should have an annotation.
     */
    private void createAppendPdf(String path, String output){
        try {
            PdfDocument doc = new PdfDocument();
            doc.appendPage();
            doc.saveToFile(path);

            doc = new PdfDocument(path);

            addAnnotation(doc.getPages().get(0));

            doc.saveToFile(output);
        } catch (Exception ex){
            ex.printStackTrace();
        }
    }

    private void addAnnotation(PdfPageBase page){
        page.getCanvas().drawString("Comment:", new PdfFont(PdfFontFamily.Times_Roman, 12), PdfPens.getBlack(), 10, 120);

        PdfPopupAnnotation testAnnotation = new PdfPopupAnnotation(new RectF(100, 100, 150, 140), "Test");
        testAnnotation.setIcon(PdfPopupIcon.Comment);
        testAnnotation.setColor(new PdfRGBColor(Color.BLUE));

        page.getAnnotationsWidget().add(testAnnotation);
    }
}


The resulting PDFs are stored in "internal storage/Android/data/com.example.spiretest/files".
The PDF "createPdf-Test" has the annotation like I would expect.
The PDF "createAppendPdf-Test2" should have the same annotation but does not have one.

Thank you for looking into this.

BTW: With Spire.PDF for C#, this works as expected.

RicoScheller
 
Posts: 35
Joined: Tue Jul 02, 2019 10:34 am

Tue Mar 02, 2021 9:51 am

Hello,

Thanks for your inquiry!

I have reproduced your issue and logged it in our issue tracking system with the ticket SPIREPDF-4076 for further investigation.

We will let you know if there is any update. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Mar 16, 2021 8:29 am

Hello

Is there any news regarding this issue?
It has now been two months since the last Android release.
Is there a timeline for when this will be fixed?

Thanks in advance.

RicoScheller
 
Posts: 35
Joined: Tue Jul 02, 2019 10:34 am

Tue Mar 16, 2021 10:40 am

Hello,

Thanks for your following up!

Our Dev team is still working on your issues, sorry to tell that there is no significant progress so far. Anyway, I urged and requested them to share any possible ETA at their earliest, once there is any good news, we will notify you immediately. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon May 03, 2021 9:05 am

Hello

It has now been two months since I reported this issue.
It has been 3.5 months since the last version for Android was released.

Honestly, I'm a bit concerned.
For the .Net and Java versions, your support and update frequency is very good.

But now I need to be able to add annotations to a PDF and it seems like you abandoned your Android port?!
Should I look for another Android PDF library?
We plan to use the licensed library in a product which needs to be relevant at least 20 years.
And thus, we need assurance, that you will support us when we encounter bugs.

So, could you please at least give me a date until when this will be fixed?

Thank you in advance.

RicoScheller
 
Posts: 35
Joined: Tue Jul 02, 2019 10:34 am

Mon May 03, 2021 10:56 am

Hello,

I just checked the status of your issue and found it has been resolved. It is now in the testing phase.
But sorry that our Test team is now having the Labor Day holiday (2021/5/1-2021/5/5). They will start the test as soon as they come back to work. And once it passes the test, we will compile a new version for you ASAP. Sorry for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Jun 07, 2021 5:55 am

Hi again

May I ask for a status update once again?.

RicoScheller
 
Posts: 35
Joined: Tue Jul 02, 2019 10:34 am

Mon Jun 07, 2021 10:49 am

Hello,

Sorry for the long silence.

Since the last fix of the ticket SPIREPDF-4076 affected the other cases, it did not pass the previous round of testing. Our dev team have made a further adjustment to the code and now this issue is in the testing phrase again. Once it passes testing, I will provide you with a new version ASAP.

Sorry for the inconvenience caused, and thanks again for your patience.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Jun 11, 2021 7:02 am

Hello,

Thanks for your patience!

Glad to inform you that we just released Spire.PDF for Android Version:3.6.2 which fixes the issue that it failed to add the annotation to PDF. (SPIREPDF-4076)

Please download the fix version from the following links to test.

Website link: https://www.e-iceblue.com/Download/pdf-for-android-via-java.html

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jun 14, 2021 6:59 am

Hi

I just tested the new version and comments are now correctly added.

However, this new version is not available on your Maven repository.
So I had to manually download it.
If your team could make this version available on the Maven repository where the previous version 3.1.0 can also be found, that would be icing on the cake with a cherry on top ;)

Thanks!

RicoScheller
 
Posts: 35
Joined: Tue Jul 02, 2019 10:34 am

Mon Jun 14, 2021 8:38 am

Hi,

Thanks for your feedback.
We will upload the new version in Maven repository ASAP. Once it is available, I will notify you.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Tue Jun 15, 2021 10:53 am

Hi,

Thanks for your patience.
The new version has been uploaed in Maven repository, please have a try.
Maven repository address: http://repo.e-iceblue.com/nexus/content/groups/public/e-iceblue/spire.pdf.android/

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF