Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Confluence Cloud] get_page_as_pdf is not working #1057

Closed
rootsj opened this issue Oct 12, 2022 · 9 comments
Closed

[Confluence Cloud] get_page_as_pdf is not working #1057

rootsj opened this issue Oct 12, 2022 · 9 comments

Comments

@rootsj
Copy link
Contributor

rootsj commented Oct 12, 2022

log.error PDF conversion not successful

I used it well until October 6th,
but it's not working since October 7th.

@glenlobo
Copy link

Facing the same issue.
Throws a message "PDF conversion not successful."

@Zad2
Copy link

Zad2 commented Oct 13, 2022

Me too, do you think that's related to https://developer.atlassian.com/cloud/confluence/changelog/#CHANGE-720 ?

@rootsj
Copy link
Contributor Author

rootsj commented Oct 17, 2022

Yes, I think it's related. https://developer.atlassian.com/cloud/confluence/changelog/#CHANGE-754
I'm using it after customizing it temporarily.

@Zad2
Copy link

Zad2 commented Oct 17, 2022

@rootsj can you share how you customized it to fix it?

@rootsj
Copy link
Contributor Author

rootsj commented Oct 18, 2022

@Zad2
I modified 'try: code' on def get_pdf_download_url_for_confluence_cloud of confluence.py.

long_running_task = True headers = self.form_token_headers log.info("Initiate PDF export from Confluence Cloud") response = self.get(url, headers=headers, not_json_response=True) response_string = response.decode(encoding="utf-8", errors="strict") task_id = response_string.split('name="ajs-taskId" content="')[1].split('">')[0] poll_url = "/services/api/v1/task/{0}/progress".format(task_id) while long_running_task: long_running_task_response = self.get(poll_url, headers=headers, not_json_response=True) long_running_task_response_parts = json.loads(long_running_task_response.decode( encoding="utf-8", errors="strict" )) percentage_complete = long_running_task_response_parts["progress"] is_update_final = long_running_task_response_parts["progress"] == 100 current_state = long_running_task_response_parts["state"] log.info("Sleep for 5s.") time.sleep(5) log.info("Check if export task has completed.") if is_update_final and current_state == "UPLOADED_TO_S3": log.info(percentage_complete) log.info("Downloading content...") log.debug("Extract taskId and download PDF.") download_url = long_running_task_response_parts["result"][6:] long_running_task = False elif not is_update_final and current_state == "FAILED": log.error("PDF conversion not successful.") return None else: log.info(percentage_complete)

using def get_page_as_pdf
Then, you can know s3 url for pdf download.

s3_url = confluence.get_page_as_pdf(page_id) response = requests.get(s3_url) pdf_content = reponse.content

If you don't want to modify the lib,
refer to the code and make it separately

@Zad2
Copy link

Zad2 commented Oct 18, 2022

Thanks, it works!

@gonchik
Copy link
Member

gonchik commented Oct 18, 2022

@rootsj Could you send PR please?

rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Oct 19, 2022
…ssian-api#1057)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
@rootsj
Copy link
Contributor Author

rootsj commented Oct 19, 2022

@gonchik
ok. I sent PR.

rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Oct 26, 2022
…ssian-api#1057)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Oct 26, 2022
…ssian-api#1057)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Oct 26, 2022
…ssian-api#1057)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Oct 31, 2022
…ssian-api#1057)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
gonchik pushed a commit that referenced this issue Oct 31, 2022
… (#1061)

* Fix def get_page_as_pdf using requests lib def get

* Fix def get_pdf_download_url_for_confluence_cloud
@ShakataGaNai
Copy link

Had this issue and patched in the PR manually, it resolved the problem.

@rootsj rootsj closed this as completed Nov 14, 2022
rootsj added a commit to rootsj/atlassian-python-api that referenced this issue Nov 21, 2022
…oud(atlassian-api#1057)"

This reverts commit 04309db.

* Since November 18th, 2022
* Confluence Cloud PDF Export was rollback
gonchik pushed a commit that referenced this issue Nov 21, 2022
…oud(#1057)" (#1081)

This reverts commit 04309db.

* Since November 18th, 2022
* Confluence Cloud PDF Export was rollback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants