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

Add Watermark to print notes #43

Open
alexisrosano89 opened this issue Nov 14, 2017 · 6 comments
Open

Add Watermark to print notes #43

alexisrosano89 opened this issue Nov 14, 2017 · 6 comments

Comments

@alexisrosano89
Copy link

Hi all!

I'm looking for a new functionality to this awesome NextCloud App. Basically, I need to add something like a WaterMark at the note when the user is gonna print it (only a text at the top of the note or a simple jpg)

My question is if is possible intercept the html code to print it, or any easy way to achieve that.

Regards!

@ThomasDaheim
Copy link
Collaborator

Hi @alexisrosano89 , looks to me that the TinyMCE editors print feature is used. A quick google didn't show any way how this could be customized.
Not sure if there is anything happening that could be intercepted. From the way it shows the printing dialogue under windows it simply calls the systems printing service with the text.

@alexisrosano89
Copy link
Author

Hello @ThomasDaheim, thanks again for your answers.

I'm developing my own print button.

I'm doing this:

  1. I'm modifying .../nextnote/js/templates.js

<div class="button" ng-click="verImprimir()" style="display: inline-block;">Print</div>\n\

  1. I'm modifying .../nextnote/js/app/controllers/NoteEditCtrl.js, adding those lines

$scope.verImprimir = function() { $scope.noteShadowCopy.$print().then(function(result) { });};

  1. I'm modifying ..../nextnote/js/app/factory/NoteFactory.js

screenshot from 2017-11-16 15-25-06

  1. Im modifying .../nextnote/controller/nextnoteapicontroller.php

screenshot from 2017-11-16 15-26-19

  1. And the last one: .../nextnote/appinfo/routes.php

Adding this: array('name' => 'nextnote_api#printing', 'url' => '/api/v2.0/note', 'verb' => 'PUT'),

But, when I click the new button, it goes to public function create($title, $grouping, $content) in the next api controller. I also try with Printing (POST), but without success.

I'm missing something??

Very thanks!

@ThomasDaheim
Copy link
Collaborator

I guess I don't know enough about the routing... But wouldn't you need /api/v2.0/note/{id} to specify the note you want to print? And all combinations with {id} are already used.

@alexisrosano89
Copy link
Author

alexisrosano89 commented Nov 16, 2017

The id is not necessary because I can print a note that is not saved (I only need the content of the note).

But yes, I am stucked at this point. All the combinations for the route /api/v2.0/note are used and always I am getting the "create" option (because the order of the array in route.php). I'm looking the best way to add a new route (like /api/v2.0/note/printing) for my new function.

If you have any idea, you are welcome to share it 👍

@ThomasDaheim
Copy link
Collaborator

Not sure why you would go back to the server for printing? Its anyways done from the client...

Maybe you would need a service to fetch the watermark from the server and add it to the printout on the client side? Mmmh, could be done via standard nextcloud api and only store the filename with the watermark as option with nextnote? Or hard-coded as a first step :-)

@alexisrosano89
Copy link
Author

alexisrosano89 commented Nov 16, 2017

Yes, at the first I was printing the watermark (it's only a png image at the top of the document) at the client side with the classic windows.print function. But I encountered that the image it's only present at the first page. The, with a workarround I could print the watermark at the top in all the pages but it was overlapping the note text 🤕

Then I found a library, FPDF that resolve my problem at the server side. But actually I'm stucked at this point.

I no need to store the watermark in the database, it's only for printing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants