So I've been searching for an answer to this problem for a while and none of the other posts offer a suitable solution.
I want to make a pdf export of a grid, but the pdf needs to have a title page. I've tried this using drawDOM, the PDF function of the grid and using forced page breaks, but I don't get the result I want. I've made a dummy example in the dojo.
https://dojo.telerik.com/IFASUwud
What I want is for the kendo-template to be placed before the grid gets drawn, so I can get a title page. Or even better, to make the drawing of the grid start on the 2nd page of the PDF. When I tried this with the PDF functions of the grid I got the exact same problem.
Depening on which div I select in drawDOM function, I either get a working title page but the multipaging gets mest up, or the multipage works but I can't get a title page because the grid will always be displayed on top.
Hope you guys can help!
I'm trying to generate a PDF report and I need the charts I generate for my HTML for the PDF file. I'm trying to send the image data to the server but when I try to load it into an image object it fails. Hoping you can help me.
-- Code on client side
kendo.drawing.drawDOM($("#ESChart"))
.then(function (group) {
return kendo.drawing.exportImage(group);
})
.done(function (data) {
chartData = encodeURI(data);
$.ajax({
method: "POST",
data: chartData,
url: "/Home/CreateFacilityReport" + location.search,
})
.done(function (msg) {
alert(msg);
})
.fail(function (data) {
alert("Failed to load svg");
});
});
-- Code on server side
public ActionResult CreateFacilityReport(string FacilityId, string chartData)
{
string myData = HttpUtility.UrlDecode(chartData.ESChart);
byte[] myBytes = Encoding.ASCII.GetBytes(myData);
using (var ms = new MemoryStream(myBytes))
{
Image myImage = Image.FromStream(ms, true, false); <---- Blows up here and gets a 'Parameter is not valid'
myImage.Save("/ESChart.png");
}
}
The following code to generate some rectangles with text items (see attached). What do I need to do to center each text item in its rectangle? I see there's a Layout, but I'm not sure how to combine rectangles, paths and groups into on of those.
var vLines = [5, 90, 175, 260, 345, 430, 515, 600];
...
$.each(vLines, function (index, value) {
var group = getBox("line " + count++, "line " + count++, "line " + count++);
group.transform(geom.transform().translate(10, value));
surface.draw(group);
});
....
function getBox(text1, text2, text3) {
var lineColor = "#9999b6";
var lineWidth = 2;
var fontNormal = "12px Arial";
var group = new draw.Group();
var rect = new geom.Rect([0, 0], [160, 75]);
var path = draw.Path.fromRect(rect, { stroke: { color: lineColor, width: lineWidth } });
group.append(path);
if (text1) {
group.append(new draw.Text(text1, new geom.Point(10, 10), { font: fontNormal }));
}
if (text2) {
group.append(new draw.Text(text2, new geom.Point(10, 30), { font: fontNormal }));
}
if (text3) {
group.append(new draw.Text(text3, new geom.Point(10, 50), { font: fontNormal }));
}
return group;
}
Thanks
Hi there,
I am using this method 'kendo.drawing.pdf.saveAs' to export pdf. Is there a callback or a promise in this method. Or is there a way to know when the download is accepted or canceled by the user?
Thanks in advance!
I am looking for an example similar to this demo:
https://demos.telerik.com/kendo-ui/pdf-export/page-layout
However when there are more table rows I need a separate page.
I can get the pdf output working correctly (including page headers and footers), but the on-screen content does not match.
a) no second page on the screen (either to scroll or via pagination controls)
b) the page header/footer from the template I used in the drawDOM options are not on the screen
Any ideas how to do this?
thank you!
Hi,
I have tried a whole bunch of the suggestions before posting here.I cannot get the pdf export to put in icons I have in my table. The table uses custom fonts and I am loading ttf fonts and everything. I am putting here table html as rendered that needs to be output. the css declaraitons and javascript code for pdf.
1. Markup - Attached in zip
2. Font Declarations: 2
@font-face {
font-family
:
'cicon'
;
src
:
url
(
'fonts/cicon.eot?c4pj34'
);
src
:
url
(
'fonts/cicon.eot?c4pj34#iefix'
)
format
(
'embedded-opentype'
),
url
(
'fonts/cicon.ttf?c4pj34'
)
format
(
'truetype'
),
url
(
'fonts/cicon.woff?c4pj34'
)
format
(
'woff'
),
url
(
'fonts/cicon.svg?c4pj34#cicon'
)
format
(
'svg'
);
font-weight
:
normal
;
font-style
:
normal
;
}
3. Javascript to produce pdf:
$(
'div.div-action-btns'
).hide();
$(
'#export-pdf'
).hide();
var
draw = kendo.drawing;
draw.drawDOM($(
'#div-grid-container'
),{avoidLinks:
true
})
.then(
function
(root) {
return
draw.exportPDF(root, {
landscape:
true
,
paperSize:
"auto"
});
})
.done(
function
(data) {
kendo.saveAs({
dataURI: data,
fileName:
'Lane-Assignments'
+ window.Stf.Utility.formatShortDate(
new
Date()) +
'.pdf'
});
$(
'div.div-action-btns'
).show();
$(
'#export-pdf'
).show();
});
4. Output PDF - Attached in zip
I need urgent help on this please.
I have a requirement where it's necessary print a piece html as PDF, everything goes well when the html is not so large, but when the size is bigger, more elements to get rendered the performance suffers, the window keeps unresponsive for some time span, that's a real problem because some browsers as IE11+ crashes when the main thread is blocked for several time, the same for FireFox, Is there any way to avoid the main thread get locked?
Here the code
01.
//Here the main thread is blocked in certain time span although it is supposed to be a async promise
02.
kendo.drawing.drawDOM($(selector), {
03.
paperSize:
"A4"
,
04.
margin:
"1cm"
,
05.
multiPage:
true
,
06.
})
07.
.then(
function
(group) {
08.
return
kendo.drawing.exportPDF(group);
09.
}).done(
function
(data) {
10.
kendo.saveAs({
11.
dataURI: data,
12.
fileName:
"file.pdf"
,
13.
proxyURL:
"/ExportToPDF"
14.
});
15.
})
I have the following function which works perfectly in Chrome but not IE11.
kendo.drawing.drawDOM($(".pagePDF"), { forcePageBreak: ".page-break" })
.then(function (group) {
var PAGE_RECT = new kendo.geometry.Rect([0, 0], [mm(215.9 - 25), mm(279.4 - 25)]);
var content = new kendo.drawing.Group();
content.append(group);
//kendo.drawing.align(content, PAGE_RECT);
kendo.drawing.fit(content, PAGE_RECT);
kendo.drawing.pdf.saveAs(group, $("#Nom").val() + ".pdf");
return kendo.drawing.exportPDF(content, {
paperSize: "Letter",
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" },
Landscape:true
});
})
It starts working in IE11 if I take out the forcePageBreak. If there are any properties, the "then" instruction is never executed. There is just nothing happening.
And, again, it is working fine in Chrome.
Can anybody help me with this problem?
Thanks in advance!
I need to download the contents of a div to a pdf. there are some currency symbols as unicode which are not getting rendered in the pdf
self.pdfPrint = function () {
kendo.drawing.drawDOM($("#content"))
.then(function (group) {
return kendo.drawing.exportPDF(group, {
paperSize: "auto",
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
})
})
.done(function (data) {
kendo.saveAs({
dataURI: data,
fileName: "file.pdf",
});
});
}