Add element <button> on ng2-pdf-viewer Angular - html

I need to display PDF file on my component using ng2-pdf-viewer, but one of its requirement,I need to add button downloadand it must overlapping PDF file, try to find any reference regarding this but none found, this is what I had tried,
component.html
<button (click)="toggle()">VIEW RECEIPT</button>
<div style="height:715px">
<pdf-viewer *ngIf="isHideReceipt" [autoresize]="true" [src]="pdfSrc" [original-size]="false"
[render-text]='false' [show-all]="false" style="display: block;position: relative"
[fit-to-page]="true">
</pdf-viewer>
<button (click)="download()">Download PDF</button>
</div>
component.ts
pdfSrc = '../../assets/pdf/bla3.pdf';
toggle() {
this.isHideReceipt = !this.isHideReceipt;
}
download() {
const blob = this.pdfSrc;
saveAs(blob, 'test1.pdf');
}
as per-requirement (button download overlapping pdf), Im trying using CSS like z-index but none work, it is possible ?
link to official ng2-pdf-viewer

Set the button element to have an absolute position and it's parent container to have a relative position. That way you'll be able to overlap onto the pdf viewer:
<button (click)="toggle()">VIEW RECEIPT</button>
<div style="position: relative; height:715px;">
<pdf-viewer *ngIf="isHideReceipt" [autoresize]="true" [src]="pdfSrc" [original-size]="false"
[render-text]='false' [show-all]="false" style="display: block;position: relative"
[fit-to-page]="true">
</pdf-viewer>
<button style="position: absolute; right: 10px; bottom: 10px;" (click)="download()">Download PDF</button>
</div>

Related

How to show primeNg sideBar only inside the child div element?

Here is my code
<div style=" background-color: yellow; height: 350px; padding-top: 45%;">
<p-button
type="button"
(click)="visibleSidebar1 = true"
icon="pi pi-arrow-right">
</p-button>
<div style="background-color: green; height: 250px;">
<p-sidebar [(visible)]="visibleSidebar1" [baseZIndex]="10000">
<h1 style="font-weight:normal">Left Sidebar</h1>
</p-sidebar>
</div>
</div>
I have use sideBar inside the child element But it is showing in outside the child element. like this sidebar in outside
But i want to show the side bar inside the child element (green area). like this this is what i expect
Have any way to achieve this? my stackBlitz
Please define below CSS properties in your "`\src\styles.css" file
p-sidebar div.p-sidebar
{
position: relative !important;
}

How to make a png file a button in html

I'm not a programmer by trade, but I'm trying to turn a PNG file into a button in html but im having trouble getting the button to be flush with the png in a way that doesn't look bad. I've googled many solutions so far but either i don't have the understanding to implement the fixes or my problems isn't what i think it is.
<a href="file:///E:/eLibrary_Jamaica_2019/Please_Click_Me_For_eLibrary.html">
<button type="submit" style="height:80px; width:360px "><img src="../../Web/media/images/FULLLOGOENACTUS 2.png" width="360" height="80" alt="" padding-right="50px" syle="content-align:center"
alt="Submit">
</button>
</a>
This is what the current code produces.
You could add the following CSS to the code:
button {
padding: 0;
}
img {
width: 100%;
height: 100%
}
This fits the png within the button and removes the button padding (buttons have padding unless you remove it). You could also add this to your inline html:
<a href="file:///E:/eLibrary_Jamaica_2019/Please_Click_Me_For_eLibrary.html">
<button type="submit" style="height:80px; width:360px; padding: 0"><img src="../../Web/media/images/FULLLOGOENACTUS 2.png" width="360" height="80" alt="" padding-right="50px" syle="content-align:center; width: 100%; height: 100%"
alt="Submit">
</button>
</a>
Side note.. you shouldn't wrap buttons in a tags. this is bad for seo, accessibility, and many other things.. Just wrapping your image in an a tag and styling accordingly will do what you're looking for whilst being compliant. A button isn't needed unless you're trying to submit a form of some sort -- and even in that case, don't wrap the button in an a tag
Use a class on your button and style it from within the style sheet using background.
<input type="button" class="button" ...>
then in your style sheet
.button
{
background: url(path/to/img.png) no-repeat ...;
cursor: pointer;
....
}
It is just always a good idea to separate your markup from your styles. I would also suggest that whatever the button actually does (unless it is just a link to something else), use javascript for that.

Angular - Primeng's confirmDialog is shown behind the ng-bootstrap's modal

I'm using the primeng and ng-bootstrap components to make a website with angular.
To capture information I use a form within an ng-bootstrap modal. When clicking on the "save" button of that modal The primeng confirmDialog should appear. The problem is that it appears behind the modal.
How can I fix it?
Here's some of my HTML:
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle" width="425" appendTo="body"></p-confirmDialog>
<ng-template #modalFormOrder let-c="close" let-d="dismiss" id="modalFormOrder">
<div class="modal-header">
...
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="c('Close click')">Close</button>
<button type="button" class="btn m-btn--pill m-btn--air btn-success" (click)="SaveEditLoadOrder()">Save</button>
</div>
</ng-template>
I'm somehow sure that both dialogs use z-index CSS property
Override the z-index CSS property with a bigger number for the element that you want to appears first, example z-index: 1001;
If you want to override Css for PrimeNG I suggest you write it on /src/styles.css . Following Example is overriding calendar CSS
.ui-calendar {
width: 100%;
height: 100%;
}
On PrimeNG documentation you can find the CSS classes to override for each component

"cursor: pointer" just not working at all

This is my angular template code:
<!-- Modal -->
<ng-template #levelsmodal let-c="close" let-d="dismiss">
<div class="modal-header">
Select the levels you want to show in the table and chart
</div>
<div id="segments-modal" class="modal-body">
<div class="row margin" *ngFor="let level of config?.data?.groups; let i = index" (click)="selectLevel(level)">
<div class="colorspan" [style.backgroundColor]="level.active ? colors[i] : 'gray'" class="colorspan">
</div>
<span class="level-labels pointer-cursor" [innerHTML]="getLabel(level)" ></span>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" (click)="c()">Close</button>
</div>
</ng-template>
The class "pointer-cursor" is plain simple:
.pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
The z-index was only added for trying if it could make some difference, but it doesn't. I also tried applying this class to other parts like the wrapper div and so, but it's just not working. I keep seeing the normal "text cursor" instead of the pointer one...
Does anybody know why this happens?
Try that
::ng-deep .pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
Edit
The ::ng-deep combinator (https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep) ensures that the defined style applies to all child elements of the component, not only elements directly created by the component.
Since the element you want to style in inside a ng-template tag (so it does not belong directly to the component), you need to use this to style its elements

ng-click= checkPhoneError() does not get called

I am newbie and inherited this code. When I click on the Call button checkPhoneError() does not get called. What is missing here? Thanks
<ion-nav-title>Status: {{name}}
<a href="{{::getPhoneNumber()}}" class="blue" ng-show="::showCallButton">
<div id="callArea"
class="button"
ng-class="::getCallButtonColor()">
Call
</div>
</a>
<div id="buttonOverlay" ng-click="checkPhoneError()"></div>
</ion-nav-title>
This is the Controller Code. So when the call button is clicked I hope to break to this funciton:
$scope.checkPhoneError = function () {
if (phoneNumberError) {
displayError();
$fileLogger.log("error", "There is no phone number for " + analysis.name);
}
else if ($scope.alertLevel != '') {
PaymentService.call(analysis.name, $scope.alertLevel);
}
};
Sorry I should have added this too, I did not realize what all was needed for people to get full context. Here is my size of the button from the CSS file. Yes I can click and the control goes to the phone and I can make a call. What I want is to know that the phone call happened. BTW this a cordova/ionic app running on Android phone:
#buttonOverlay {
position: absolute;
height: 100%;
width: 60px;
right: 0;
top: 0;
padding-top: 3px;
opacity: 0;
}
I Googled and got some hint and tried this. Now I can break into my function but the call button does not show :(. However when I hover there the cursor becomes live(becomes a hand) and I can click the execution breaks into my function, now only if I can see the call button.
<ion-nav-title>Status: {{name}}
<div id="buttonOverlay" ng-click="checkPhoneError()">
<a href="{{::getPhoneNumber()}}" class="blue" ng-show="::showCallButton">
<div id="callArea"
class="button"
ng-class="::getCallButtonColor()">
Call
</div>
</a>
</div>
</ion-nav-title>
Finally I hit the solution thanks to Google!! Here is the working code. So what was happening was a-tag will set the link and make it automatically clickable. So the default ng-click was masking my ng-click. All I had to do was to override the default ng-click with my own.
<ion-nav-title>Status: {{name}}
<a href="{{::getPhoneNumber()}}" class="blue" ng-click="checkPhoneError()" ng-show="::showCallButton">
<div id="callArea"
class="button"
ng-class="::getCallButtonColor()">
Call
</div>
</a>
<div id="buttonOverlay" ></div>
</ion-nav-title>
Finally I hit the solution thanks to Google!! Here is the working code. So what was happening was a-tag will set the link and make it automatically clickable. So the default ng-click was masking my ng-click. All I had to do was to override the default ng-click with my own.
<ion-nav-title>Status: {{name}}
<a href="{{::getPhoneNumber()}}" class="blue" ng-click="checkPhoneError()" ng-show="::showCallButton">
<div id="callArea"
class="button"
ng-class="::getCallButtonColor()">
Call
</div>
</a>
<div id="buttonOverlay" ></div>
</ion-nav-title>