Telerik Forums
Kendo UI for Angular Forum
1 answer
25 views
Kendo UI is  it possible to draw  directly on the kendo-pdfviewer from the angular component library.
Things II have tried:
-embedding it in a drawing component to draw over - the problem here being  that the kendo-pdfviewer is removed from  the  page completely to make way  for the  canvas
-I tried to super impose the canvas over the kendo-pdfviewer with a relative off set of -y in CSS - The problem here was that although it worked for the most part the canvas then blocked the  PDF controls such as scrolling (especially if set to the same size).
-I tried to hook the canvas in the PDF to draw - here I just did not see any success. It seemed like  either I was drawn over or it simply was not used. Not the canvas is height="2376" x width="1836"
Here is some rough code for the last option I tired:
public pdfLoad(pdfViewerLoadEvent: PDFViewerLoadEvent)
  {
    this.pdfViewerContext = pdfViewerLoadEvent.context;
    this.pdfViewerContext.pdfDoc.getPage(1).then(async (page)=>{
      var scale = this.pdfViewerContext.zoom;
      var viewport = page.getViewport({scale});
      var canvas: HTMLCanvasElement  = document.getElementById('the-canvas') as HTMLCanvasElement;
      var context = canvas.getContext('2d')!;

      canvas.width = Math.floor(viewport.width * scale);
      canvas.height = Math.floor(viewport.height * scale);
      canvas.style.width = Math.floor(viewport.width) + "px";
      canvas.style.height =  Math.floor(viewport.height) + "px";

      context.beginPath();
      context.arc(300, 300, 100, 0, 2);
      context.stroke();

      var transform: number[] | undefined = scale !== 1
         ? [scale, 0, 0, scale, 0, 0]
         : undefined;
      var transform: number[] | undefined = [2,0,0]

      await page.render({
          canvasContext: context!,
          transform: transform,
          viewport: viewport
      });

      context.beginPath();
      context.arc(300, 300, 100, 0, 2);
      context.stroke();
    });
  }

Martin
Telerik team
 updated answer on 11 Mar 2024
0 answers
69 views

Hi There,

I'm currently trying to use the Kendo PDF Export Function using Kendo Drawing and have been struggling to split the page of dynamic widgets into 2 and it cuts off the bottom of the page and doesnt go onto a second page even when using force page break.

 

Is there any function to check if the page is overflowing? so I can adjust the table template with extra white space.

Or how can I amend this issue and make the page flow onto 2 pages even if the element ends up getting split in 2.

Attempt without page breaking:

const drawing = awaitdrawDOM(this.elm.nativeElement, { paperSize: 'a4', scale: 0.45, }); const myData = await exportPDF(drawing); saveAs(myData, `test.pdf`);

 

<div #elm >
...content...
</div>

 

In the image of the pdf, the bottom of the grid is cut off, then I did the same with text and the text template isnt even visible and doesnt flow onto the next page.

 

Attempt with Page breaking:

const drawing = awaitdrawDOM(this.elm.nativeElement, {
      paperSize: 'a4',
      scale: 0.45, 
      forcePageBreak: '.page-break',
    });

const myData = await exportPDF(drawing);

saveAs(myData, `test.pdf`);

 

Child Component with page breaking:

<div class=".page-break"></div>
<div class="h-full flex flex-col">
...content...
</div>


 

 

Grid component with page breaking

<div class="h-full flex flex-col page-break">

<ngContainer... *gridTemplate></ng-container>

...content...
</div>

<ngTemplate  #gridTemplate>
...Kendo Grid...
</ngTemplate>

ProgramBear
Top achievements
Rank 1
 updated question on 04 Dec 2023
0 answers
56 views

Under the export options for charts, there's an example of how to fit a chart to the size of your paper. Part of this example includes some kind of conversion function and a rectangle constant.

function mm(val: number): number {
  return val * 2.8347;
}

const PAGE_RECT = new geometry.Rect([0, 0], [mm(210 - 20), mm(297 - 20)]);

However, there is absolutely no explanation for these numbers. Am I converting to or from millimeters, and what's the other unit? Why am I doing this? Where are these 210 and 297 numbers coming from in the page rectangle? I can see that the minus 20 is accounting for the 1cm margin set in the PDF below, but other than that I have no idea what the origin of these numbers is.

Can someone please translate these magic numbers? Telerik, can you please add comments to the example code explaining?

Megan
Top achievements
Rank 1
Iron
Iron
 asked on 26 Sep 2022
0 answers
36 views

I am using kendo ui drawing pad for obtaining digital signatures. I am able to save it as .svg file using save as and display the svg link in console.

But I am unable to extract the svg link from the function to use it outside ExportSVG. Is there any way I can do that?

Pranav
Top achievements
Rank 1
 updated question on 04 Apr 2022
0 answers
75 views

I am using Kendo Angular UI drawing to generate signature using method "exportSVG()" and is generating url is 64base svg (data:image/svg+xml;base64, ..............) and saving to DB, thing are working fine till I save the data, but while I bind this generated base64 to my display signature component it seems like "cropped". 

I have tried to resize this image but no luck as its 64based image. 

muhammed
Top achievements
Rank 1
 asked on 17 Feb 2022
1 answer
428 views

Hello Team,

We are using the Kendo drawing library(drawDom and exportPDF methods) for PDF export in Angular 12. We can have multiple charts and grids that can be dynamically added to be downloaded as PDF and these charts and grids can be further customized by end user. So this has to be handled from client-side only. 

When we are trying to export to PDF, the process is very slow. On debugging, we observed that the exportPDF method is taking a lot of time to complete its execution.

Please suggest if there are any ways/work-arounds by which we can achieve some performance improvement in the PDF export.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 25 Oct 2021
1 answer
409 views

I have a donut chart with rounded ends in Kendo UI for jQuery running exactly as the client wants. However, I need this to be using Kendo UI for Angular instead. I believe this is supported if I use Drawing Visuals, but I can't figure out how to port over what I have for my jQuery version into the Angular version.

My working stackblitz of the jQuery donut is here: https://stackblitz.com/edit/web-platform-szmuv9

My Angular version that I am trying to work on is here:

https://stackblitz.com/edit/angular-bi2dsw

My app.component.ts:


@Component({
selector: 'my-app',
  template: `
      <kendo-chart>
        <kendo-chart-legend [visible]="false"></kendo-chart-legend>
        <kendo-chart-area background="none"></kendo-chart-area>
        <kendo-chart-tooltip>
          <ng-template kendoChartSeriesTooltipTemplate
                       let-value="value" let-category="category" let-series="series">
              {{ category }} ({{ series.name }}): {{ value }}%
          </ng-template>
        </kendo-chart-tooltip>
        <kendo-chart-series>
          <kendo-chart-series-item *ngFor="let series of model; let outermost = last;"
                                   type="donut" [startAngle]="90"
                                   [holeSize]="60" [margin]="10"
                                   [name]="series.name" [data]="series.data"
                                   field="value" categoryField="category" colorField="color">
          </kendo-chart-series-item>
        </kendo-chart-series>
      </kendo-chart>
    `,
})

the tempdata.ts file:


export const tempdata = [
  {
    data: [
      {
        category: 'demand',
        value: '75%',
        color: '#009a8c',
      },
      {
        category: 'late',
        value: '25%',
        color: '#e31b23',
      },
    ],
  },
  {
    data: [
      {
        category: 'All',
        value: 500,
        color: '#065aa3',
      },
    ],
  },
];

I am going through your API references as well (https://www.telerik.com/kendo-angular-ui/components/drawing/api/), but haven't had much luck.  Can anyone help point me in the right direction?


Yanmario
Telerik team
 answered on 20 Oct 2021
0 answers
106 views

Hi, 

I'm working on using Draw and Export a Signature feature to save a drawn object in SVG format while it works on the desktop browser on Mouse event but not working on Mobile browser by Touch event, and is there a way to implement this feature works by Touch event on mobile browser?

Thanks,

idnks
Top achievements
Rank 1
 asked on 30 Jun 2021
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?