Free Support Forum -

Failing to save document as PDF

I’m currently evaluation the latest Aspose.Words java library using a ruby interface (using rjb).

My code is really simple:

doc = Rjb::import(“com.aspose.words.Document”).new
builder = Rjb::import(“com.aspose.words.DocumentBuilder”).new
builder.write(“Hello world!”)"/tmp/out.pdf")

When trying to save to a “.doc” or “.docx” or “.odt” it works fine. But as soon as I try to save to “.pdf” it fails with “Fail: unknown method name `to_str’”. :frowning:


Thanks for your request. When you render documents to PDF, XPS or convert to EPUB that requires embedding of fonts into a document, then Aspose.Words needs to have access to TrueType fonts. If you run Aspose.Words on a Windows system, then by default it will search for fonts in the system Windows\Fonts folder. But if you run Aspose.Words on a Linux system, it does not have a default location for fonts and you need to specify it explicitly.

Use the new com.aspose.words.FontSettings class and setFontsFolder/setFontsFolders methods to specify the location of TrueType fonts.


DocumentBuilder b = new DocumentBuilder();

b.getFont().setName("Water on the Oil");


b.writeln("Hello World!");

b.getDocument().save("TestHelloWorld Out.pdf");

Best regards,

Thanks, now it’s working :slight_smile: