distributev / the-app

The App
MIT License
0 stars 2 forks source link

download-pdf-button-should-not-show-in-the-generated-pdf-file #105

Open distributev opened 8 years ago

distributev commented 8 years ago

download-pdf-button-should-not-show-in-the-generated-pdf-file

luismanuel001 commented 8 years ago

This is just here to show that one can use angular directives on document templates, so if we pull it out of the template it kind of defeats the purpose.

I can just remove it now since you tested that directives correctly work on templates, or replace with something else more appropriate if you wish.

distributev commented 8 years ago

How can I see that if place it outside the template it will work?

Just for testing purposes can you place this directive in the enclosing hexo template where the documents are rendered? Just to see it can be done and it works fine.

luismanuel001 commented 8 years ago

It was never specified that it needed to work outside of the template, but even if wanted to do so, the directive needs the merge.pdf_permalink (ie. <download-pdf-button pdf-permalink="merge.pdf_permalink"></download-pdf-button>), and that variable is not available on the parent hexo template which is in the /source/document/index.md file.

distributev commented 8 years ago

Somehow I was vaguely thinking to the technical difficulty you are describing here (though not as clear as you describe here) and I was curious if it's indeed and issue and what the solution would be.

About the fact that it was not specified you are right in the sense it is not written explicitly as a requirement. On the other hand some things self describe like the fact that a PDF invoice with a big button inside Download PDF does not make much sense.

Please try to think to a possible solution and what effort would require. Like defining 2 divs in the invoice template with some kind of conventions that the first div (with a well known ID) encloses the actual document and the next enveloping div (with a well known ID) will be there only as a placeholder for the <download-pdf-button pdf-permalink="merge.pdf_permalink". When you will print the PDF you know that you need to print the first div (with a well known ID) and you know that the 2nd div is there only for the download button. Download button should be optional in the sense that there might be HTML documents which will not use the directive.

How much effort a solution like this will require? First we need to discuss the solution here.

luismanuel001 commented 8 years ago

I still don't quite understand what is the requirement. Is it that you want the blue button to show on the document when accessing it from the url, but you want it hidden when the pdf gets generated? if that's so, how would having 2 divs help on this?

If that's indeed the desired behavior, we can just have a flag (ng-hide="{{isPDF}}") that will hide the button (or any directive/html with that flag) on the server when generating the pdf.

distributev commented 8 years ago

Yes that is the desired behavior

When viewing the HTML the user has the option to download the PDF also. But when the PDF is download the Download Button should not be rendered since it does not make sense.

You solution is great.