francogarcia / GD-PDF

Create PDF files using Godot Game Engine.
zlib License
37 stars 8 forks source link

Convert the module to a GDExtension #8

Open francogarcia opened 1 year ago

francogarcia commented 1 year ago

This a reminder to investigate porting this module as a extension.

See #4 and #6 and the documentation.

Firty commented 1 year ago

Hello, I am very interested in your project. I use Godot to make applications that need to generate pdf. I'm currently using external software to do this. But I want something simpler. I was able to compile using your tips, but when calling the create_document and even save_document functions, nothing is happening... Making an extension would be great!

francogarcia commented 1 year ago

Hello, @Firty, How are you?

I was able to compile using your tips, but when calling the create_document and even save_document functions, nothing is happening...

Unfortunately I cannot help with the issue, as I cannot reproduce it. When I wrote the patch for #6, I have only tested in on Linux.

Assuming LibHARU has been compiled correctly, perhaps the issue is the path or write permissions?

If you are following the example from the documentation,

pdf.create_document("/tmp/DejaVuSans.ttf", "/tmp/DejaVuSerif.ttf")
# ...
pdf.save_document("/tmp/my_doc.pdf")

As the module does not use Godot's abstractions for the filesystem, you need to provide a valid path on with the current user has write permissions. Thus, it cannot be a path starting with res:// or user://; rather, it must be an absolute or a relative path to the file system.

In the example, /tmp/ is the temporary folder in the Linux Unix operating system. You may change it as needed.

For instance, on Windows for user Firty it could be something resembling C:/Users/Firty/Desktop/my_font.ttf and C:/Users/Firty/Desktop/output.pdf. On Linux, the same example would resemble /home/Firty/Desktop/my_font.ttf or ~/Desktop/my_font.ttf.

If you have a Godot-specific path, you can convert it to the operating path following the documentation. See ProjectSettings.globalize_path() in the documentation entry, as it has a caveat when the project is not running in the editor.

Finally, I have not used this project since 2016; if I recall correctly, LibHARU had issues handling special characters in file paths. For instance, if the path has accented characters or diacritics in any part of the string (including the user name), the calls fail. Thus, if possible, it may be better to restrict characters in paths to ASCII-compatible ones.

Special characters in the document should work fine, though, provided the chosen font supports them.

If neither the path or permissions are the problems, then it might be an issue configuring LibHARU before compiling it.

Making an extension would be great!

I will try investigating it when I have time, though it will probably need to wait a couple months and it has low priority overall.

Furthermore, as mentioned in #6, I cannot provide iOS / macOS builds as I do not own Apple devices. Unless it has changed, cross-compiled software is not accepted in the official stores. Even it has changed, I would need to check if the old ways are still supported.

I use Godot to make applications that need to generate pdf. I'm currently using external software to do this.

Depending on the desired complexity, Pandoc or LaTeX may provide better quality PDF files. Though they are external software and will require prior configuration.

Best regards, Franco

shafnaz commented 1 year ago

Any updates so far with GDExtension?

francogarcia commented 1 year ago

Hello, @shafnaz, How are you?

Thanks for you interest.

Unfortunately, as mentioned in https://github.com/francogarcia/GD-PDF/issues/8#issuecomment-1605724157, a module will have to wait:

I will try investigating it when I have time, though it will probably need to wait a couple months and it has low priority overall.

Apologies for the news.

Best regards, Franco