Unable to read PDF Fields JAVA

Hi,
It is an environment issue and not a problem with the code as it runs fine locally. Do we need to install fonts on AIX server?
Is there a way to set fonts at run time for ASPOSE pdf to be generated?
Please find the input pdf attOwnership Legal Entity Shareholding.pdf (108.7 KB)
ached.

Please advise urgently. This same exception can be seen on many forum discussion threads for ASPOSE PDF as mentioned earlier. Do you have a solution?

Hi, I am a Priority Support customer and I still have not received an explanation or solution in the last 3 days.
I am not even able to post an issue in the Paid Support forum. The ASPOSE PDF OWNER value is mandatory in that forum and it does not populate thus making it impossible to post.

Can you look into this ? There is no point purchasing this paid support for your Product. Absolutley frustrating.

@pexy_poulose,
You can specify the custom font directory and need to add a folder in font folder lists as follows:

[Java]

String path = "path/to/my/folder";
List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add(path);
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);

You can also use a font directly from a file path as follows:
[Java]

// The path to the documents directory.
String dataDir = "C:/";
// Create new document instance
Document pdfDocument = new Document();
// Add page to pages collection of PDF file
com.aspose.pdf.Page page = pdfDocument.getPages().add();
// Create TextFragment instance with sample text
TextFragment fragment = new TextFragment("Sample Text in OTF font");
// Find font inside system font directory
// Fragment.TextState.Font = FontRepository.FindFont("HelveticaNeueLT Pro 45 Lt");
// Or you can even specify the path of OTF font in system directory
fragment.getTextState().setFont(FontRepository.openFont(dataDir + "space age.otf"));
// Specify to emend font inside PDF file, so that its displayed properly,
// Even if specific font is not installed/present over target machine
fragment.getTextState().getFont().setEmbedded(true);
// Add TextFragment to paragraphs collection of Page instance
page.getParagraphs().add(fragment);
dataDir = dataDir + "OTFFont_out.pdf";
// Save resulting PDF document.
pdfDocument.save(dataDir);

@pexy_poulose,

We are looking into this matter and will let you know once it is resolved.

@pexy_poulose,
In order to post in the paid helpdesk, you need to use exactly the same username which you were using to post in the old Priority Support forum. If this does not help, then please send us your registered username. We will investigate it.

Best Regards,
Imran Rafique

Will this work only for Text Fragment? I am not using Text Fragmentry in my code. Only setting values Field.setValue
How can fonts be set on field for target machine?

Can you try setting the values in the first pdf and deploy on Unix box and check whether it works? Is Aspose only meany to be used for Windows?

You guys have nor provided the root cause of the issue and not even reproduced on a same environment

@pexy_poulose,
We can explicitly set font on a field by using a line of code as narrated below and the specified font should be installed on AIX. However, if the font in not installed in the target machine, then you can place a font file in the folder and add this folder path in the list of Aspose.Pdf for Java API. Aspose.Pdf API will also search the required font from this folder path.

[Java]

pdfField.setDefaultAppearance(new com.aspose.pdf.DefaultAppearance("ComicSansMS", 10, Color.BLACK));

[Java]

String path = "path/to/my/folder";
List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add(path);
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);

Meanwhile, please clarify that when you executed your same code in AIX, does it show an error as “specified method is not supported” or not setting an accurate font on the field. I asked because you are able to generate an output PDF. We are preparing an environment of AIX server and required a little time. In our local Windows environment, we can change the font of a field for your input PDF (Ownership Legal Entity Shareholding.pdf). We will execute the same scenario in AIX server and let you know about our findings. We are sorry for the inconvenience caused.

The error just says specified method is not supported"

The issue is resolved by setting the path explicitly :

String path = “path/to/my/folder”;
List fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add(path);
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);

There is no need to set the default appearance. Just make sure all required .TTF files are present in the path.

I think this should have already been added to your api as ASPOSE WORDS handle fonts on the same AIX server without setting the path.
What is the issue with PDF ? Please make sure you add this as a release note for different environment usage and confirm with the user who is buying your product beforehand.

@pexy_poulose,
Did you mean that the Aspose.Pdf for Java API does not handle fonts located in the default path on AIX server? Please share the path of the directory which you added in the list.

Best Regards,
Imran Rafique

@pexy_poulose,

We have logged an enhancement under the ticket ID PDFJAVA-36863 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Best Regards,
Imran Rafique