How to add a pdf file manually as part of the mendix project. - Mendix Forum

How to add a pdf file manually as part of the mendix project.


We have a usecase wherein we want to add a pdf document as a part of our mendix application.

We want to show a help document that is in pdf format and that has to be part of mendix application.

We tried keeping the file in <projectdirectory>/resources folder and then tried to access it via GetResourcePath java action. This works fine in the local environment but when we push the changes to mendix cloud environment, then it is not able to locate that pdf file.

Please refer to another forum which suggested to put the file in the resources folder.


3 answers

@Pranav indeed the file separator is different locally and in the cloud. Use  FIle.separator instead of a hardcoded slash


String fileName = "nx_reporting_and_analytics.pdf";
String resourceFolderPath = Core.getConfiguration().getResourcesPath().toString();
String filePath = resourceFolderPath +File.separator+fileName;



Maybe a silly question, but what kind of slashes do you use in the file path? Do you account for linux vs windows differences?
Can you show the entire code where you read the file?


An alternate approach which I would suggest is as below

  1. Create an entity which is having a generalization System.FileDocument (You can name it as ‘PDFDocument’)
  2. Have an admin page for the administrator to upload a single PDF document using this entity.
  3. Retrieve and show this Help file on the page which you want to show. Restrict the access to the normal user only to download the file.


Hope this helps