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.

Mon Jul 22, 2024 7:25 am

Hello, I have the issue stated in the subject line.

I'm using the following code to add a polygon annotation:

Code: Select all
var doc = PdfDocument.MergeFiles(files.ToArray());
var page = doc.Pages[0];

var points = new PointF[] { new(0.5, 1.0), new(7.5, 1.0), new(8.5, 4.0), new(1.5, 4.0), new(0.5, 1.0) };
var annotation = new PdfPolygonAnnotation(page, points)
{
    Name = "name",
    Author = "somebody",
    BorderEffect = PdfBorderEffect.SmallCloud,
    ModifiedDate = DateTime.Now,

    Subject = "some text",
};
annotation.Text = "some text";
page.Annotations.Add(annotation);

doc.Save(outputPath);

(where "files" is an array of filepaths for single-page pdfs, and "outputPath" is the output path)

One of the input pdfs has a shape that links to a file (example attached). After adding an annotation to it like this, the file link vanishes.

Philipp Lange
 
Posts: 11
Joined: Fri Jun 14, 2019 9:24 am

Mon Jul 22, 2024 10:06 am

Hello,

Thanks for your inquiry.
I tested your case with the latest Spire.PDF Pack(Hot Fix) Version:10.7.12 , but didn't reproduce your issue. I attached my result document for your reference. Are you using the latest version? If not, please upgrade and try again.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Mon Aug 05, 2024 7:48 am

Hello William,

I was using a lower version, but unfortunately for me the problem persists with 10.7.21 (upgraded via NuGet). Is there anything else I can provide to aid in reproducing the issue?

Philipp Lange
 
Posts: 11
Joined: Fri Jun 14, 2019 9:24 am

Mon Aug 05, 2024 9:59 am

Hello,

Thanks for your reply.
Sorry, I overlooked that you added the annotation after merging the documents. I re-tested and indeed reproduced the issue you mentioned. I have logged this to our tracking system with ticket SPIREPDF-6951, and our development team will further investigate and fix it. Once there is any progress, I will inform you as soon as possible. In addition, as a solution, you can save the merged document first, then reload this document and add the annotation. I uploaded my test code for your reference.
Code: Select all
String[] files = new String[] {@"example.pdf"};
PdfDocumentBase doc = PdfDocument.MergeFiles(files);
doc.Save("tmp.pdf", FileFormat.PDF);
PdfDocument pdfDocument = new PdfDocument("tmp.pdf");
var page = pdfDocument.Pages[0];
PointF[] points = new PointF[]
      {
            new PointF(0.5f, 1.0f),
            new PointF(7.5f, 1.0f),
            new PointF(8.5f, 4.0f),
            new PointF(1.5f, 4.0f),
            new PointF(0.5f, 1.0f)
      };
var annotation = new PdfPolygonAnnotation(page, points)
{
    Name = "name",
    Author = "somebody",
    BorderEffect = PdfBorderEffect.SmallCloud,
    ModifiedDate = DateTime.Now,

    Subject = "some text",
};
annotation.Text = "some text";
page.Annotations.Add(annotation);
pdfDocument.SaveToFile("res.pdf", FileFormat.PDF);

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF

cron