Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Unable to run on Unix

$
0
0
I was able to generate a PDF on Windows, but when I try it on a Unix machine, I get the following error:

Exception in thread "main" java.lang.AssertionError: Cannot read a name from the name table in a font.
        at com.aspose.pdf.internal.p242.z1.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z28.m2(Unknown Source)
        at com.aspose.pdf.internal.p189.z28.m6(Unknown Source)
        at com.aspose.pdf.internal.p189.z28.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z11.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z11.<init>(Unknown Source)
        at com.aspose.pdf.internal.p189.z8.m8(Unknown Source)
        at com.aspose.pdf.internal.p189.z8.m6(Unknown Source)
        at com.aspose.pdf.internal.p189.z8.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z10.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z10.m1(Unknown Source)
        at com.aspose.pdf.internal.p189.z10.m1(Unknown Source)
        at com.aspose.pdf.internal.p414.z13.m2(Unknown Source)
        at com.aspose.pcl.composer.PDFComposer.<init>(Unknown Source)
        at aspose.pdf.Pdf.bindPCL(Unknown Source)
        at com.aspose.pdf.ADocument.m1(Unknown Source)
        at com.aspose.pdf.ADocument.<init>(Unknown Source)
        at com.aspose.pdf.Document.<init>(Unknown Source)
        at pcltopdf.Converter.generatePdf(Converter.java:123)
        at pcltopdf.Converter.main(Converter.java:74)

I looked for other questions with same problem most of them say I need to provide font for Unix, I added a TrueType font and PostScript font next to my jar file, and added the following line to my existing code

Document.addLocalFontPath(path); // path contains location of my jar file and fonts

Any help regarding my issue would be appreciated.

--Edit: Here is the complete code

/**
* Generates PDF file from the PCL and properties file and saves it in the directory found in the properties.
* @param pclFilePath canonical path of PCL file.
* @param properties contains parameters such as output directory, image path, etc...
* @return generated PDF file.
*/
private static Pdf generatePdf(String pclFilePath, Properties properties) throws IllegalArgumentException {
if(pclFilePath == null || pclFilePath.equals("")) {
throw new IllegalArgumentException("PCL file path is empty.");
}
if(properties == null || properties.isEmpty()) {
throw new IllegalArgumentException("Properties object is empty.");
}

String path = "/usr/openwin/lib/X11/fonts/TrueType";
List<String> paths = new ArrayList<String>();
paths.add("/usr/share/fonts/");
Document.setLocalFontPaths(paths);
paths.add(path);
Document.setLocalFontPaths(paths);
System.out.println("font path start");
for (int i=0; i<Document.getLocalFontPaths().size(); i++){
System.out.println(Document.getLocalFontPaths().get(i));
}
System.out.println("font path end");

// Printing the font path the Document class has stored.
System.out.println("Font Path from Document:");
for(int i = 0; i < Document.getLocalFontPaths().size(); i++) {
System.out.println(Document.getLocalFontPaths().get(i));
}
System.out.println("Finished printing Font Path");
Document doc = new Document(pclFilePath, new PclLoadOptions());
return doc;
}



--- Hello Again, below some advanced testing:
//Create PDF document
Pdf pdf1 = new Pdf();
pdf1.setTruetypeFontMapPath(path);
//Add a section into the PDF document
Section sec1 = pdf1.getSections().add();
//Add a text paragraph into the section
Text text1 = new Text("hello World -  Arial");
text1.getSegments().get_Item(0).getTextInfo().setFontName("Arial");
sec1.getParagraphs().add(text1 );
//Save the document
pdf1.save("HelloWorld.pdf");

the above code is causing exception: 
INFO: Error - Font 'Arial' not found. Please make sure the customer font file is correctly set.

NOTE: i need to solve the initial first problem, the last comment about font "Arial" not found is just a remark that i came though when testing

NOTE #2: I am having this issue on Solaris 10

Viewing all articles
Browse latest Browse all 3131

Trending Articles