Posted 22 January 2021, 3:56 am EST
Hi there,
I want to ask a couple of questions about Wijmo PDF control.
-
"
-
“Is there any shorter way to convert HTML to PDF?”
-
“How can we inject flex grid into a PDF?”
"
Thanks
Forums Home / Wijmo / General Discussion
Posted by: chhavi.sethi on 22 January 2021, 3:56 am EST
Posted 22 January 2021, 3:56 am EST
Hi there,
I want to ask a couple of questions about Wijmo PDF control.
"
“Is there any shorter way to convert HTML to PDF?”
“How can we inject flex grid into a PDF?”
"
Thanks
Posted 24 January 2021, 8:08 pm EST
Hi Chhavi,
• For converting HTML to pdf you could use printDocument class of wijmo. Please refer to the following demo:
https://www.grapecity.com/wijmo/demos/Core/PrintDocument/purejs
• You could use print document class to add flexgrid to PDF too. For more controlled/customized control over export you may use the FlexGridPdfConverter class. Following demos demonstrates the usage of FlexGridPdfConverter:
https://www.grapecity.com/wijmo/demos/Grid/ImportExportPrint/PDF/ExportToFile/purejs
https://www.grapecity.com/wijmo/demos/Grid/ImportExportPrint/PDF/ExportToPdfDocument/purejs
Regards
Sharad
Posted 25 January 2021, 9:08 pm EST
Thanks for the solution. Still have couple of queries:
Posted 27 January 2021, 4:42 pm EST
1). We are sorry but PrintDocument class is an extension of the browser’s print functionality so it is not possible to skip the print screen and directly export to PDF. For exporting directly to Pdf we should use the PdfDocument class.
2). Image alignment option works only when we specify a rectangle/size for the image. Please refer to the following code snippet:
doc.drawImage(image, null, null, {
width: doc.width,
height: 50,
stretchProportionally: true,
align: pdf.PdfImageHorizontalAlign.Right
});
3). We could use the lineTo() method. You may refer to the following code snippets:
doc.paths
.moveTo(doc.x, doc.y)
.lineTo(doc.x + doc.width, doc.y)
.stroke();
Sample: https://codesandbox.io/s/wijmo-starter-forked-9utmy?file=/src/index.js
PDFDocument graphics demo:
• https://www.grapecity.com/wijmo/demos/PDF/DrawingGraphics/purejs
API References:
• PdfDocument: https://www.grapecity.com/wijmo/api/classes/wijmo_pdf.pdfdocument.html
• PdfPaths; https://www.grapecity.com/wijmo/api/classes/wijmo_pdf.pdfpaths.html