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

feat: implement PdfService using mikehaertl/php-pdftk #3806

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

luka-nextcloud
Copy link
Contributor

@luka-nextcloud luka-nextcloud commented Jul 3, 2024

  • Resolves:
  • Target version: main

Summary

Follow-up

@luka-nextcloud luka-nextcloud self-assigned this Jul 3, 2024
@luka-nextcloud luka-nextcloud added the 3. to review Ready to be reviewed label Jul 4, 2024
Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments inline :)

@elzody elzody force-pushed the feat/pdf-template-workflow branch from ac56967 to 6f85ff4 Compare July 25, 2024 13:50
Base automatically changed from feat/pdf-template-workflow to main July 25, 2024 16:10
@luka-nextcloud luka-nextcloud force-pushed the feat/pdf-template-workflow-update branch from dd31b09 to 88eb9d7 Compare July 31, 2024 14:15
@juliushaertl juliushaertl force-pushed the feat/pdf-template-workflow-update branch from 88eb9d7 to 25fcae6 Compare August 1, 2024 14:16
@juliushaertl
Copy link
Member

juliushaertl commented Aug 1, 2024

@luka-nextcloud I pushed a few fixes while reviewing testing. Mainly to make the matching of fields work when fillling in to what is described below and to not overwrite the existing file

@elzody I extended the OCS API also to be able to pass a destination along. However I noticed we have not really typed the fields array structure in the server API and here. Currently it seems to just use array<int,array{content: string}>. We should properly document that in the server API and all methods around here. What I currently lack to know is if the array key is actually using the Field class index value or is just a numeric index based on what the vue frontend in files loops over.

Sample curl commands


 curl -H 'OCS-APIRequest: true' https://admin:admin@nextcloud.local/ocs/v2.php/apps/richdocuments/api/v1/template/fields/extract/37526\?format\=json
 
 curl -X POST -H 'OCS-APIRequest: true' https://admin:admin@nextcloud.local/ocs/v2.php/apps/richdocuments/api/v1/template/fields/fill/37526\?format\=json -H "Content-Type: application/json" --data '{"fields":[{"content":"FooBar"}],"destination":"foobar.pdf"}'

@elzody
Copy link
Contributor

elzody commented Aug 1, 2024

@juliushaertl The index should be the string index from the field class, afaik. The second curl command looks like it should have something like '{"fields":["someIndex": {"content":"FooBar"}],"destination":"foobar.pdf"}', else I'm not sure how it would know which form control the content being passed belongs to

@juliushaertl
Copy link
Member

All right, the extra object with a content property originates from the Collabora API?

@elzody
Copy link
Contributor

elzody commented Aug 1, 2024

@juliushaertl I think so, if I remember correctly you pass the fields to the endpoint in richdocuments as an array, and it loops over the fields passed and extracts the form control index and its matching properties (content, alias, etc.) then passes an object looking something like this to the Collabora API in JSON format:

{
  "ContentControls.ByIndex.0": {
    "content": "Something"
  },
  "ContentControls.ByIndex.1": {
    "alias": "Something else"
  }
}

And yeah because it allows changing multiple controls at a time the index is needed to specify what data each control should have via its index. Hopefully that makes sense, not sure if that's what you're asking

@juliushaertl juliushaertl force-pushed the feat/pdf-template-workflow-update branch 2 times, most recently from 38bc17a to daf510c Compare August 7, 2024 14:50
@juliushaertl juliushaertl force-pushed the feat/pdf-template-workflow-update branch 2 times, most recently from 1180562 to 331450e Compare August 16, 2024 18:45
luka-nextcloud and others added 2 commits August 21, 2024 13:41
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl juliushaertl force-pushed the feat/pdf-template-workflow-update branch 2 times, most recently from d5b15a0 to 58ceee1 Compare August 21, 2024 17:00
…ce documents

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl juliushaertl force-pushed the feat/pdf-template-workflow-update branch from 58ceee1 to 55cbed3 Compare August 23, 2024 09:48
@juliushaertl juliushaertl merged commit fed8437 into main Aug 26, 2024
66 checks passed
@juliushaertl juliushaertl deleted the feat/pdf-template-workflow-update branch August 26, 2024 07:33
@juliushaertl
Copy link
Member

/backport to stable30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Ready to be reviewed
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

3 participants