- Home
- Forum
- Angular - EJ 2
- mark
mark
I use Angular code to add markers so I can draw on a pdf file.
The problem that sometimes the markers are drawn below the drawings that I created on the pdf.
How to put the markers above the drawing in yellow.
I already tried with z-index but it doesn't work
this my Typescript code
second problem
When I click on the print button, it only prints the pdf without the markers or drawings.
Attachment: pdfviewer_4572e550.zip
Hi
After analyzing the code snippet, it seems you are creating a canvas or element and appending it to the PDF viewer container or page div. If you print or save the PDF, these appended elements won't be visible, is that the issue you're mentioning. If this is the case, these elements won't be part of the PDF content. Instead, you can create a custom stamp or image annotation and add it to the PDF viewer. This approach will ensure that the added content is visible and properly embedded in the PDF. Kindly refer the sample below.
Sample: Ug6zy6 (forked) - StackBlitz
Regards,
Priyadharshini
Thak you for your replay
and how about firt probléme ?
Thanks
Hi Aitbouhou Adam,
As per the provided code snippet, you have added the element as an image. As previously mentioned, you can create a custom stamp or image annotation and add it to the PDF viewer. The solution remains the same for both scenarios.
Regards,
Priyadharshini
Hello
How to add un hyperLInkText with AddAnottaion Stamp ?
Thank
Hi Aitbouhou Adam,
Currently, Syncfusion PDF Viewer does not directly support adding a hyperlink. However, you add the hyperlink using PDF Library. We have provided the documentation below for your reference.
Documentation: Working with Hyperlinks | Syncfusion
Regards,
Priyadharshini
Hello, I am in the process of modifying my code to comply with your recommendations.
and when I test I find that my elements are not well positioned.
Could you help me?
Here is the world and an example
Attachment: pdfviewers_a86ad175.zip
Hi
Kindly let us know whether you are specifying the width and height in pixels or points. Our component is fully loaded based on pixels, so if you are using points, please convert them to pixels and try again.
Additionally, please specify whether the issue is related to the image's X and Y position or its width and height. If the issue persists after converting points to pixels, kindly provide the image data and the PDF file so we can analyze the problem and provide a solution.
Code Snippet:
public ConvertPointToPixel(number: any): number { return (number * (96 / 72)); } |
Regards,
Priyadharshini
Hello
based on the example below. How we can add a click event to the text we added.
https://stackblitz.com/edit/angular-iykefk-8x2aboum?file=package.json,src%2Fapp.component.ts
Thank you very mutch
Have a nice day
Hi Aitbouhou Adam,
If you're adding text as free text annotations, you can utilize the annotation select event, which is triggered when you click on the added annotation (e.g., free text or any other supported annotation). However, if your requirements differ from what has been mentioned above, please provide more details about the exact scenario you are working with. This will help us offer more targeted guidance.
API reference: Angular PDF Viewer API component - Syncfusion
Regards,
Priyadharshini
Hello
I will explain my problem to you.
in a PDF, sometimes I need to add drawings (stamps) and many text (freeText) this text must be clickable (listnerEvent) and redirect to another page. (PJ)
the texts must be on the images if they intersect.
Attachment: prints_190c8f49.zip
Hi Aitbouhou Adam,
We have provided a sample in which selecting a stamp annotation redirects to page 5 using the annotation select event. Similarly, you can modify it as needed to suit your requirements based on the annotation types. Please review it and let us know if it meets your needs or if any further modifications are required.
Sample: Ug6zy6 (forked) - StackBlitz
Regards,
Priyadharshini
Good morning
How can I display my annotations only when I click on the print button on the pdfview? so that they can be printed?
thanks
We are checking on the reported query and will provide further details later tomorrow.
Regards,
Priyadharshini
Hi Aitbouhou Adam,
We have provided a sample based on your requirements. In this sample, the printStart event is used to add annotations using the addAnnotation API, and the printEnd event removes the added annotations after a timeout. This ensures that the annotations are visible only in the print window.
Please review the sample and let us know if it meets your expectations or if you require any further clarification.
Sample: Aj3usxru (forked) - StackBlitz
Regards,
Priyadharshini
Hello
I use this code to create points in pdf.
It works but when I click on the zoom button or zoom out. it redraws the points, but it keeps the old points even though I deleted container.
Here is my code
Thanks you
------------------------------------------------------------------------------------------------------------------------------------------------
public clearMarkersAndShapes(): void {
const pinsContainer = this.#elementRef.nativeElement.querySelector(
`#${this.pdfId}_pageViewContainer`
);
while (pinsContainer?.hasChildNodes()) {
const lastChild = pinsContainer.lastChild;
const nodeName = lastChild?.nodeName.toLowerCase();
if (nodeName === 'i' || nodeName === 'span') {
pinsContainer.removeChild(lastChild as Node);
} else {
break;
}
}
}
public addMarkersToPage(): void {
if (!this.planId() || !this.markersList || this.markersList.length === 0) return;
const pageCount = this.pdfViewerObj().pageCount;
const pinsContainer = this.#elementRef.nativeElement.querySelector(
`#${this.pdfId}_pageViewContainer`
);
if (!pinsContainer) {
return;
}
for (let p = 0; p <= pageCount; p += 1) {
const page = this.#elementRef.nativeElement.querySelector(
`#${this.pdfId}_pageDiv_${p}`
);
if (!page) return;
const pageMarkers = this.markersList.filter(marker => marker.page === p);
if (!pageMarkers || pageMarkers.length === 0) return;
pageMarkers.forEach(marker => {
// add icon
this.addIcon(marker, pinsContainer, page);
// add Text
if (marker.toString) {
this.addText(marker, pinsContainer, page);
}
});
}
}
private addIcon(point: IPdfMarker, container: HTMLElement, page: HTMLElement): void {
const icon = document.createElement('i');
icon.className = 'icon-required';
icon.style.position = 'absolute';
icon.style.fontSize = `${this.fontSize}px`;
icon.style.zIndex = '3';
icon.style.color = point.color;
const top =
(point.y * parseInt(page.style.height.replace('px', ''))) / 100 +
parseInt(page.style.top.replace('px', '')) -
this.fontSize / 2;
icon.style.top = `${top}px`;
const left =
(point.x * parseInt(page.style.width.replace('px', ''))) / 100 +
parseInt(page.style.left.replace('px', '')) -
this.fontSize / 2;
icon.style.left = `${left}px`;
icon.addEventListener('click', () => {
this.#pdfViewerService.setSelectedPoint(point);
const rect = container.getBoundingClientRect();
if (point.inputId) {
this.contextMenu().open(rect.top + top + 15, rect.left + left);
} else {
this.#pdfViewerService.openMarker(
this.category(),
this.formId(),
this.#planOptions.objectRelation1Option.relationObject,
this.#planOptions.objectRelation1Option.view
);
}
});
container?.appendChild(icon);
}
Hi
You can update the size of the created element by adjusting its dimensions according to the zoom value. For example, you can multiply the element's width and height by the current zoom factor to scale it proportionally. This will ensure that the element's size is consistent with the zoom level. Please let me know if you need further assistance with the implementation. Additionally, please share the video reference so that I can analyze it further and provide a solution.
Regards,
Priyadharshini
- 16 Replies
- 3 Participants
-
AA Aitbouhou Adam
- Jan 23, 2025 02:10 PM UTC
- Feb 18, 2025 08:00 AM UTC