Set default font for freetext annotation - pdftron-react-native

Product: pdftron-react-native

Product Version: Latest

Please give a brief summary of your issue:
We’re trying to change the default font of the freetext annotation from Helvetica to PlusJakarta on IOS but can’t seem to find anything about it on the documentation. How can we change the default font-family?

Please provide a link to a minimal sample where the issue is reproducible:

1 Like

Hello Arthur,

Are you able to share how you’re adding the PlusJakarta font file to your app? Could you share a minimal working sample project we can use to investigate this issue?

I can share how it’s being added, but is it really necessary? The font is working properly throughout the project. But the problem itself is not related to the font-family specified, it’s about chaging the default font-family of the freetext annotation to any other font-family. How would one change the default font which is Helvetica to any other font-family?

The specific problem we’re having is for some reason, the freetext annotation does not work with the Helvetica font, the content inside the tags of the xfdfCommand property comes empty, but when changed to any other font-family, it works. So we’re trying to change the default font for that reason.
The freetext annotation works fine on android, but it does not work with the default font(Helvetica) on IOS

Hi Arthur,

In that case would you be able to share the document containing the annotation(s) which are not displaying correctly?
We would expect the annotation’s appearance to display similarly on both Android and iOS. How is the annotation being created?

I’m sending a video with the mentioned behavior. The video is a bit laggy since it’s being recorded inside a virtual machine. This is happening in every document.

Hello Arthur,

Are you able to reproduce this issue on one of our sample apps? Otherwise would you be able to share a minimal working sample project we can use to reproduce the issue?

I just tested it on the GitHub - PDFTron/react-native-sample: Sample to demonstrate integrating PDFTron in React Native repo and it seems to be working properly, but you’re using react 18.0.0 and react-native 0.69.4. We’re using react @ 18.2.0 and react native 0.71.0. Are you sure it works correctly with the versions mentioned? I’m trying to update the sample app to the more recent versions, but i’m getting a lot of compatibility errors. Or could you provide a sample with those versions?

I don’t think it’s any problem with implementation on our part, since any other font-family works properly, I’m leaning towards package incompatibility.

Hi Arthur,

I just tested on react@18.2.0 and react native 0.72.1 by making some minor changes to the file in our sample app:

//#import <React/RCTAppSetupUtils.h>
#import <RCTAppSetupUtils.h>
//  RCTAppSetupPrepareApp(application);
  RCTAppSetupPrepareApp(application, YES);
//  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"example", initProps);
  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"example", initProps, YES);

Unfortunately I am still unable to reproduce the issue. Are you able to run the sample with those changes and confirm if you still see the issue?

Hey Jamie, @jamie

I tested it too with those versions on the sample and it’s working properly as well. I really don’t know what’s causing helvetica to not work.
Is there any way to change the default font that opens up with the freetext annotation? I don’t know if it’s going to solve the problem but it’s worth a shot.

There is nothing regarding the default font of the freetext annotation on the documentation.

Hello @arthur.paes,

Apologies for the delay.
We have this API for setting the default font for a free text annotation:

Please let us know if that works for you.

Hey, Jamie

Thank you for the reply.

If it’s not too much to ask, could you show me an implementation example on react native to change the default font of the free text annotation?

Best regards.

This API is only available in the native SDK so you would need to add it inside your iOS app project in Xcode, e.g. in AppDelegate.m after the app finishes launching.