DryCreations / pdfproject

Adapting starter code that uses itext7, into a program that can draw onto pdfs, and export files to pdf
1 stars 3 forks source link

Hrg Action43: Added ability to add text fields to pdf #58

Closed hgongloff closed 3 years ago

hgongloff commented 3 years ago

List Any Relevant Actions or Tasks

Actions

Action 43

Tasks

Task 16.1

Description of Changes

I added the ability to create text fields inside the pdf.

Relevant Artifacts

Before

Before

After

After

Other Comments

I had to create a new folder inside of resources called manipulate_pdf to store both the original and updated pdf. For some reason I could only alter the names of the pdfs if they were not inside the resources folder. Because of this it is not possible to reopen the pdf in our canvas. This could be fixed by having the canvas also use the folder I created for its pdf but I realize this would cause a lot of merge conflicts and might not be an ideal fix.

hgongloff commented 3 years ago

After reviewing your implementation of these form elements, I'm noticing it isn't following the same patterns our previous implementations are.

It appears that on click you are directly modifying the pdf that has been opened. This is not consistent with any of the other drawing tools, as they only draw on the canvas until save.

You may want to look over how DrawRectangle is implemented, the execute method draws the representation of a rectangle on a canvas, and pdfExecute is later used to draw on a pdf when the document is saved.

I brought this up during our group meeting 2 weeks ago. I discussed how I couldn't show the changes on the canvas using Itext7 and I remember we came to the conclusion that we wouldn't actually edit the pdf inside of our canvas and instead would use our canvas to add text boxes and then be able to edit them in other pdf manipulators such as Adobe.

DryCreations commented 3 years ago

After reviewing your implementation of these form elements, I'm noticing it isn't following the same patterns our previous implementations are. It appears that on click you are directly modifying the pdf that has been opened. This is not consistent with any of the other drawing tools, as they only draw on the canvas until save. You may want to look over how DrawRectangle is implemented, the execute method draws the representation of a rectangle on a canvas, and pdfExecute is later used to draw on a pdf when the document is saved.

I brought this up during our group meeting 2 weeks ago. I discussed how I couldn't show the changes on the canvas using Itext7 and I remember we came to the conclusion that we wouldn't actually edit the pdf inside of our canvas and instead would use our canvas to add text boxes and then be able to edit them in other pdf manipulators such as Adobe.

I think there is a misunderstanding on what I mean. You don't need to show the changes that happen on the pdf, as you are not editing the pdf yet. the execute method is strictly for drawing a graphical representation of the item, not the actual item on the pdf. It hasn't been drawn on the pdf yet. You can use the execute method to draw a makeshift text field, then in pdfExecute you would include the majority of the code in your handle method to actually place it on the pdf. This will make it so it can still be handled with undo and redo.

You are correct that we won't need to interact with elements that are already on the pdf, or add text to textboxes we already drew. But we did not say we would immediately modify the pdf upon clicking the canvas, this will make it so the undo function no longer works with this action.

hgongloff commented 3 years ago

After reviewing your implementation of these form elements, I'm noticing it isn't following the same patterns our previous implementations are. It appears that on click you are directly modifying the pdf that has been opened. This is not consistent with any of the other drawing tools, as they only draw on the canvas until save. You may want to look over how DrawRectangle is implemented, the execute method draws the representation of a rectangle on a canvas, and pdfExecute is later used to draw on a pdf when the document is saved.

I brought this up during our group meeting 2 weeks ago. I discussed how I couldn't show the changes on the canvas using Itext7 and I remember we came to the conclusion that we wouldn't actually edit the pdf inside of our canvas and instead would use our canvas to add text boxes and then be able to edit them in other pdf manipulators such as Adobe.

I think there is a misunderstanding on what I mean. You don't need to show the changes that happen on the pdf, as you are not editing the pdf yet. the execute method is strictly for drawing a graphical representation of the item, not the actual item on the pdf. It hasn't been drawn on the pdf yet. You can use the execute method to draw a makeshift text field, then in pdfExecute you would include the majority of the code in your handle method to actually place it on the pdf. This will make it so it can still be handled with undo and redo.

You are correct that we won't need to interact with elements that are already on the pdf, or add text to textboxes we already drew. But we did not say we would immediately modify the pdf upon clicking the canvas, this will make it so the undo function no longer works with this action.

Ok then so the idea would be too draw a rectangle representing the text box. Then after user let's go the rectangle is drawn and the pdf would be edited to include the text box?

DryCreations commented 3 years ago

I have made a branch with the basic idea of what I'm talking about implemented. Check the pull request here for more details https://github.com/DryCreations/pdfproject/pull/74