brantje / nextnote

A full Evernote / OneNote style WYSIWYG note editor for Nextcloud / ownCloud. Join our telegram at: https://t.me/NextNote
GNU Affero General Public License v3.0
163 stars 19 forks source link

Add Watermark to print notes #43

Open alexisrosano89 opened 6 years ago

alexisrosano89 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.