Cannot use isTranslateNativePdfOnly field in Cloud Translate API

I’m using native pdfs, so I’d like to enable the isTranslateNativePdfOnly field to raise my page limit to 300.

document_input_config = {
        "content": document_content,
        "mime_type": mine_type,
    }

    response = client.translate_document(
        request={
            "parent": parent,
            "target_language_code": "en",
            "document_input_config": document_input_config,
            "isTranslateNativePdfOnly": True,
        }
    )

This field doesn’t seem to be recognized…

(baseenv) ubuntu@ip-172-31-73-230:~/revrec-dev$ python base_image/services/translation_service/google/doc_to_doc_translation.py ../docs/test_larger.pdf
2023-07-17 21:13:30 DEBUG    Checking None for explicit credentials as part of auth process...
2023-07-17 21:13:30 DEBUG    Checking Cloud SDK credentials as part of auth process...
Traceback (most recent call last):
  File "base_image/services/translation_service/google/doc_to_doc_translation.py", line 78, in <module>
    translate_document(file_path)
  File "base_image/services/translation_service/google/doc_to_doc_translation.py", line 50, in translate_document
    "isTranslateNativePdfOnly": True,
  File "/home/ubuntu/anaconda3/envs/baseenv/lib/python3.6/site-packages/google/cloud/translate_v3/services/translation_service/client.py", line 974, in translate_document
    request = translation_service.TranslateDocumentRequest(request)
  File "/home/ubuntu/anaconda3/envs/baseenv/lib/python3.6/site-packages/proto/message.py", line 566, in __init__
    "Unknown field for {}: {}".format(self.__class__.__name__, key)
ValueError: Unknown field for TranslateDocumentRequest: isTranslateNativePdfOnly

Any advice? Same issue occurs on version 3.11.2 on Python 3.11.

Good day @chromecast56 ,

Welcome to Google Cloud Community!

To limit the page of online native pdf translation to 300 in Python, you need to set the attribute

"is_translate_native_pdf_only": True

and not the “isTranslateNativePdfOnly”, You are getting the error unknown field since the attribute “isTranslateNativePdfOnly” does not exist in the class TranslateDocumentRequest(version 3.11.2), however the attribute that you are trying to refer to is "is_translate_native_pdf_only".

You can check this link for more information:
https://cloud.google.com/python/docs/reference/translate/latest/google.cloud.translate_v3.types.TranslateDocumentRequest

Hope this helps!