Apsose API-Python

Hello, Is there an Aspose API code in Python to provide the results for multiple documents?

Sincerely,
Sagar Anvekar

What is the easiest way to learn Python for the new user?

@saanvekar

You can please follow the guidelines specified over below article in API documentation in order to use Aspose.PDF in Python:

Dear Asad,

Thank you for the reply.

I read the documentation provided but does it provide the list of errors when a pdf is passed into the code?
I am looking for a python code that will provide the errors in all the pdfs that are uploaded. Is it possible?

Sincerely,
Sagar Anvekar

@saanvekar

Would you please share what type of errors you are talking about? Do you want to check if provided PDF is valid and if it is not, list the errors that it has? Please share a bit more details with us so that we can share further feedback with you.

Dear Asad,
Yes. When a pdf is passed through a code it will list the errors that Pdf has? The types of errors that were provided by you. Link: Perform PDF/UA Compliance test via Aspose.PDF - Get List of Errors - #13 by saanvekar

I am looking for an API call that will let us upload multiple documents and for each of the pdf document it will tell us the errors for that pdf

Let me know if you have any questions

Sincerely,
Sagar Anvekar

@saanvekar

These errors are about PDF/UA Compliance tests and the API already produces a log file during conversion that contains all the errors with their code and description. You can read that file in order to get the error list. Please let us know in case you need further information OR our understandings are not correct about your requirements.

Dear Asad,

Thank you for the reply

The provided link contains four API calls

  1. Working with Document Conversion
  2. Working with Document Object
  3. Working with Pages
  4. Working with Text

Can you please tell which one should I use? Also we don’t want to convert any document into PDF as we are directly working with them. We are only concerned with the errors a pdf gets when it’s scanned for accessibility. Let me know if you have any questions

Sincerely,
Sagar Anvekar

@saanvekar

Would you pleas clarify that about which provided link you are talking about here.

Furthermore, if you are validating PDF documents for accessibility, you can use the below code snippets in order to do that:

Document doc = new Document(dataDir + "outputxa.pdf");
boolean isValid = doc.validate(dataDir + "out_log.xml", PdfFormat.PDF_A_2U);

Dear Asad,

By 4 api calls I meant 4 codes. Apologies for not being clear

I was hoping if you could show me how can we include the code your provided to validate PDF documents for accessibility. Can we have short meeting?

Sincerely,
Sagar Anvekar

@saanvekar

Validate() is a method of Document Class which can be called with the arguments after initializing the Document. In the given examples, the Document object is being created in the code and you can use its methods as per your requirements. You can take any example where Document object is being used and call the validate method to verify if the PDF file is a valid tagged PDF or not.

We encourage providing support via our support forums. Please feel free to create a post here in case you need further information.

1 Like

Thank you Asad.

Can you please paste here the final code to use in Python to get the error list for a pdf document? It would be helpful

Sincerely,
Sagar Anvekar

@saanvekar

We are preparing an example for you to validate the PDF document and will share with you soon. Please give us some time.

Thank you Asad

Dear Asad,

Any update on the ticket?

Sincerely,
Sagar Anvekar

@saanvekar

We will be sharing an example in this week. Please give us little time.

We apologize for the inconvenience.

Sure. Thank you Asad

Any updates on the ticket Asad?

Sincerely,
Sagar Anvekar

@saanvekar

Please note that the existing examples of using Aspose.PDF in Python was built using Python 2.7 which has been obsolete now. Therefore, compiling them using the latest version of Python and JRE 1.8 is taking time. We will surely share our feedback with you as soon as we get some results. Your patience is highly appreciated in this regard.

Furthermore, please check the following code snippet which we prepared to validate a tagged PDF document:

class ValidatePDFDocument:
    def __init__(self, dataDir):
        self.dataDir = dataDir
        self.Document = jpype.JClass("com.aspose.pdf.Document")
        self.PdfFormat = jpype.JClass("com.aspose.pdf.PdfFormat")

    def main(self):

        # Open a pdf document.
        doc = self.Document()
        pdf = self.Document()
        pdf = self.dataDir + 'outputpdf.pdf'
        doc.validate(self.dataDir + "log.xml", self.PdfFormat.PDF_A_2U)

        print("log file has been created successfully.")

@saanvekar

A task as PDFJAVA-41484 has been logged in our issue management system to update the examples in API documentation according to the latest available version of the Python. We have associated the ticket with this forum thread and you will be able to get its status as soon as it is resolved. We apologize for the inconvenience caused.