PdfAnnotationEditor#importAnnotation not importing with correct font

Hi,

We are trying to import xfdf into pdf, where the xfdf contains freetext annotation.
The xfdf was exported from adobe acrobat reader, and the freetext annotation was written in font called Noto Sans JP.
However, after importing xfdf using aspose.PDF and saving to a pdf file, the annotation was written in different font.

Throughout this investigation, Noto Sans JP was installed in the computer.
The code for importing xfdf and otuput of it is attached.

Kind regards,
hiraki

Investigation code is below.

	void main() throws Exception {
		// a xfdf exported from adobe acrobat reader, containing freetext written in noto sans jp
		// we modified the f tag for security reasons (it contained my pc path)
		var xfdf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
				+ "<xfdf xmlns=\"http://ns.adobe.com/xfdf/\" xml:space=\"preserve\"\r\n"
				+ "><annots\r\n"
				+ "><freetext color=\"#FFFFFF\" creationdate=\"D:20240419131813+09'00'\" flags=\"print\" date=\"D:20240419131831+09'00'\" name=\"cda6697f-4f5e-4516-94ae-ef98e390ca6b\" page=\"0\" rect=\"182.399597,724.054138,369.599152,769.920166\" subject=\"テキストボックス\" title=\"C1201\"\r\n"
				+ "><contents-richtext\r\n"
				+ "><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:24.2.0\" xfa:spec=\"2.0.2\" style=\"font-size:12.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal;font-family:'Noto Sans JP';font-stretch:normal\"\r\n"
				+ "><p dir=\"ltr\"\r\n"
				+ ">noto sans freetext&#xD;のとさんすふりーてきすと</p\r\n"
				+ "></body\r\n"
				+ "></contents-richtext\r\n"
				+ "><defaultappearance\r\n"
				+ ">0 G 0.898 0.1333 0.2157 rg 0 Tc 0 Tw 100 Tz 0 TL 0 Ts 0 Tr /NotoSansJP 12 Tf</defaultappearance\r\n"
				+ "><defaultstyle\r\n"
				+ ">font: 'Noto Sans JP',sans-serif 12.0pt; text-align:left; color:#E52237 </defaultstyle\r\n"
				+ "></freetext\r\n"
				+ "></annots\r\n"
				+ "><f href=\"white.pdf\"\r\n"
				+ "/><ids\r\n"
				+ "/></xfdf\r\n"
				+ ">";

		// load pdf, load xfdf, create output stream
		// replace the generateInputStream
		try (var pdfInputStream = generateInputStream("util/pdf/white.pdf");
				var doc = new Document(pdfInputStream);
				var editor = new PdfAnnotationEditor();
				var outputStream = new FileOutputStream("output.pdf");) {
			// import xfdf
			editor.bindPdf(doc);
			editor.importAnnotationsFromXfdf(new ByteArrayInputStream(xfdf.getBytes()), new AnnotationType[] {AnnotationType.FreeText});
			// save to file
			editor.save(outputStream);
		}

The pdf we are trying to import to is below.
white.pdf (185.4 KB)

The output pdf is below. It was not written in Noto Sans JP.
image.png (17.3 KB)

@hiraki.uk

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-43849

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.