We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception in com.aspose.ms.System.f?

Hello,

i try a small code snipplet from the examples to convert documents from pdf to pdf/a.
The documents passed the validator, some of them where converted successfully and with others, i get an exception in “com.aspose.ms.System.f”. I don’t know why and what to do.
This is my code:
boolean canConvert = pdfDocument.validate(“Validation_log.xml”, com.aspose.pdf.PdfFormat.PDF_A_1B);
if (canConvert) {
pdfDocument.convert(“Conversion_log.xml”, com.aspose.pdf.PdfFormat.PDF_A_1B, com.aspose.pdf.ConvertErrorAction.Delete);

‘canConvert’ was ‘true’ and Validation_log looks fine, but convert() fails:

Exception in thread “main” class com.aspose.ms.System.f: Specified argument was out of the range of valid values.
com.aspose.pdf.a.b.b.a.i.a(Unknown Source)
com.aspose.pdf.a.b.b.a.l.(Unknown Source)
com.aspose.pdf.a.b.e.d.i.g(Unknown Source)
com.aspose.pdf.a.b.e.d.k.a(Unknown Source)
com.aspose.pdf.a.b.e.d.k.a(Unknown Source)
com.aspose.pdf.a.b.e.d.k.(Unknown Source)
com.aspose.pdf.a.i.a.b.i(Unknown Source)
com.aspose.pdf.a.i.a.b.a(Unknown Source)
com.aspose.pdf.a.d.a(Unknown Source)
com.aspose.pdf.ADocument.convert(Unknown Source)
com.aspose.pdf.Document.convert(Unknown Source)
piag.test.ConvertPDFToPDFA.(ConvertPDFToPDFA.java:39)

Any idea?

Thanks
-klaus

Edit: Now i tried with 4.4.0 and get following exception:

Exception in thread “main” class com.aspose.ms.System.e: Key cannot be null
Parameter name: key
com.aspose.ms.System.a.h.get_Item(Unknown Source)
com.aspose.pdf.a.c.e.b.f$a.a(Unknown Source)
com.aspose.pdf.a.f.a.a(Unknown Source)

Hi Klaus,


We are sorry for the inconvenience caused. Can you please share your problematic document here? So we will investigate the issue and will update you accordingly.

Best Regards,

Thank you.


No problem. I’ve attached a zip-File with my test environment.
I tested my code and two different pdfs with java6 and java7 and aspose-pdf-4.3.1 and 4.4.0.
The (different) results are in the directories. You will find it.

Regards
klaus

Hi Klaus,


Thanks for sharing the resource files.

I have tested the scenario with latest release of Aspose.Pdf for Java 4.4.0 in Eclipse JUNO application running over Windows 7(x64) with JDK 1.7 and I am unable to notice any exception during conversion process. For the sake of testing, I have used all the PDF documents present in individual folders of package which you have shared. However, I have observed that resultant files are not PDF/A_1b compliant. For the sake of correction, the problem has already been logged in our issue tracking system as PDFNEWJAVA-33606. The development team will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

PS, when converting PDF file to PDF/A format, there is no need to call validate(…) method when using convert(…) method because validation is automatically performed during conversion process.
We get the same exception ("Key cannot be null") on version 4.4. We're just trying to extract text:

try (FileInputStream fileInputStream = new FileInputStream(pdfFile)) {
PageCollection pageCollection = new Document(fileInputStream).getPages();
int numberOfPages = pageCollection.size();
StringBuilder stringBuilder = new StringBuilder(100);

for (int i = 1; i <= numberOfPages; i++) {
TextAbsorber textAbsorber = new TextAbsorber();
textAbsorber.visit(pageCollection.get_Item(i)); // <- exception here
stringBuilder.append(textAbsorber.getText());
}

return new StringReader(stringBuilder.toString());
}

The odd thing is that in our case, the same code somehow works correctly on Windows even though it fails on both Linux and Mac OS X. So if you're having trouble reproducing it, it could be worth trying a different platform.

Hi there,


We are sorry for the inconvenience caused. I have tested the scenario at Ubuntu Server 13.10, but I am afraid we are unable to notice the exception. Can you please share your linux envoirnment details so we try to replicate the issue. Moreover, we are testing the scenraio at Mac OS X and will update you ASAP.

Best Regards,

If you're having trouble reproducing it, here's a full example which doesn't use any of our own code.

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;

import com.aspose.pdf.Document;
import com.aspose.pdf.License;
import com.aspose.pdf.PageCollection;
import com.aspose.pdf.TextAbsorber;

public class PdfConversionTest
{
    private static final String LICENCE_DATA = "<>";

    public static void main(String[] args) throws Exception
    {
        new License().setLicense(new ByteArrayInputStream(LICENCE_DATA.getBytes(StandardCharsets.UTF_8)));

        File dir = new File("/INSERT BASE DIR HERE");
        File inputFile = new File(dir, "x00982a00-x009a0840.pdf");
        File outputFile = new File(dir, "x00982a00-x009a0840.txt");

        try (InputStream inputStream = new FileInputStream(inputFile);
             OutputStream outputStream = new FileOutputStream(outputFile);
             PrintStream output = new PrintStream(outputStream, false, "UTF-8"))
        {
            PageCollection pageCollection = new Document(inputStream).getPages();
            int numberOfPages = pageCollection.size();

            for (int i = 1; i <= numberOfPages; i++)
            {
                if (i > 1)
                {
                    output.print("\n\f");
                }

                TextAbsorber textAbsorber = new TextAbsorber();
                textAbsorber.visit(pageCollection.get_Item(i));
                output.print(textAbsorber.getText());
            }
        }
    }
}

Attaching the example file I have been testing with, since it’s data-dependent as well as OS-dependent.

Hi there,

Thanks for sharing source code/document. We have managed to reproduce the reported Null key exception on linux using Aspose.Pdf for Java 4.4.0 and logged it in our bug tracking system as PDFNEWJAVA-33904 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

We are also getting this exception on CentOS using 4.4.0. Can anyone give us an general time frame when this bug will be addressed? We are in the middle of purchasing Aspose.PDF for Java and this bug could be a show stopper for us.

Many thanks.

Hi John,


Thanks for your inquiry. Please download latest release of Aspose.Pdf for Java and set font path for your environment as suggest below. Hopefully it will help you to fix the issue.

com.aspose.pdf.Document.setLocalFontPath(path);

Please feel free to contact us for any further assistance.

Best Regards,

Can you give an example of what the setLocalFontPath() call should look like when there is more than one font path, as is the case on Linux and Mac OS X?


The Javadoc for the method is completely empty in version 4.5.0.

All the other Aspose APIs we’re using accept a list or an array for the font paths.

Hi there,


Thanks for your feedback. We are looking into your requirements and will get back to you soon.

Best Regards,

I’m not sure if this will be helpful to anyone or not, but what we are seeing in our situation is that the problem isn’t necessary just the font path, but also that the actual font the PDF contains/refers to is not installed in the Linux environment we’re testing in (all of our tests were passing on Windows, but many were failing on Linux). We’re performing more tests, but that’s what it’s looking like so far.

To the Aspose Team… Does Aspose distribute font packs either with their libraries or as a separate download with the purchase of a library? Seems like this would be a way to help minimize this type of platform dependent issue.

Thanks.

Interesting.


1. If the font is missing, Aspose really should be choosing a sensible fallback font, which is what a normal PDF reader would be doing.

2. If we’re just extracting text, why does it even have to look for the font?


To nuix:

1. Agree

2. In our case, we are replacing text.

Regards

Hi there,

nuix:
Can you give an example of what the setLocalFontPath() call should look like when there is more than one font path, as is the case on Linux and Mac OS X?

The Javadoc for the method is completely empty in version 4.5.0.

All the other Aspose APIs we're using accept a list or an array for the font paths.


After further investigation, we have logged an enhancement ticket as PDFNEWJAVA-33946 in our issue tracking system for setting more than one fonts in Linux and Mac OS X. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,
Hi John,

jalchin:
I'm not sure if this will be helpful to anyone or not, but what we are seeing in our situation is that the problem isn't necessary just the font path, but also that the actual font the PDF contains/refers to is not installed in the Linux environment we're testing in (all of our tests were passing on Windows, but many were failing on Linux). We're performing more tests, but that's what it's looking like so far.

Thanks for your feedback. We have logged an enhancement ticket, PDFNEWJAVA-33945, in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress via this forum thread.

jalchin:

To the Aspose Team... Does Aspose distribute font packs either with their libraries or as a separate download with the purchase of a library? Seems like this would be a way to help minimize this type of platform dependent issue.

I am afraid Aspose doesn't provide fonts. We are sorry for the inconvenience caused.

Best Regards,

Hi there,


Thanks for your patiene. Please check following code snippet, a use case when there is more than one font path. Hopefully it will help you to accomplish your requirments.


//adding
a
new font path<o:p></o:p>

String path = "c:\\fonts\\";

com.aspose.pdf.Document.addLocalFontPath(path);

//geting the list for standard font directories in different OS

java.util.List list = com.aspose.pdf.Document.getLocalFontPaths();

//seting the user list for standard font directories

list.add("c:\\fonts2\\");

list.add("c:\\fonts3\\");

com.aspose.pdf.Document.setLocalFontPaths(list);

//Restoring list for standard font directories by default.

com.aspose.pdf.Document.restoreLocalFontPath();

Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as PDFNEWJAVA-33946) have been fixed in Aspose.Pdf for Java 4.5.1.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.