We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

print and export

Hi Team, I am using html native code inside diagram - and I am trying to use the print and export option.

I have followed this https://www.syncfusion.com/kb/13298/how-to-print-or-export-the-html-and-native-node-into-image-format , but unable to figure out what is the correct nuget package I need to download. I am using MVC version 5.2.7.

I have downloaded  Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.nupkg however , this doesn't  seem to support DiagramExportUtility . Could you please tell me what is the nuget package I should be looking at? also if could please share a sample code on how do to convert this html to pdf.

I am trying to pass diagramContent and width to controller

    var diagram = form.data('diagram');

    var htmlData = diagram.getDiagramContent(["file:///..."]);

    var size = diagram.getDiagramBounds();

    var jsonResult = { htmlData: { htmlData: htmlData, width: size.width } };

   


7 Replies

BM Balasubramanian Manikandan Syncfusion Team February 27, 2023 02:10 PM UTC

We will validate and update with more details on March 1st, 2023.



GD Gobinath Dhamotharan Syncfusion Team March 1, 2023 01:38 PM UTC

Hi Sourangsu, 

We created a sample to achieve your requirement. In this  https://www.syncfusion.com/kb/13298/how-to-print-or-export-the-html-and-native-node-into-image-format KB documentation page, we are converting HTML to PDF document by using WebKit rendering engine. Our WebKit rendering engine becomes an older rendering engine, some of the advanced bootstrap, CSS styles are not supported in the WebKit rendering engine. WebKit based HTML to PDF conversion are deprecated. We introduced a new Blink rendering engine, which supports the latest bootstrap styles and advanced web features. Please refer to the sample below for your reference. We will update the KB document with blink rendering engine

Regards,

Gobinath


Attachment: HTML_to_PDF_49a692ff.zip


SD Sourangsu Dasgupta March 5, 2023 06:50 AM UTC

Thanks for the example, I am able to print the html node to image format! however I am facing another 

problem now, the diagram I am trying to print is large enough that one needs to scroll along the y axis (in some cases one might need to scroll along x axis as well to see the full image). 

following are my diagram specs:


whenever I try to print / export it always prints the image which is visible without scrolling, which is probably equal to diagram height (559px). How can I print the whole page height which is about 3545px.. can you please help me.

To start with, I have not initialized pagesettings while creating the diagram, but later on since on PrintImage method we are using region:  "PageSettings" so I tried to set the PageSettings as well with height and width equal to diagram's html layer. still, it was only printing the part of the screen which can be seen without scrolling.


Also, when I try to print it shows page 1/3 where page is the only page having image, page 2 and page 3 remains empty.  This is my code


resultTarget: function (returnData) {

            var diagram = form.data('diagram');

            diagram.printImage(returnData, {

                fileName: "diagram",

                mode: "Data",

                format: "png",

                region: "PageSettings",

                stretch: "Meet",

                pageHeight: 1600,

                pageWidth: 900,

                pageOrientation: 'Portrait',

                bounds: {

                    x: 0,

                    y: 0,

                    height: 1600,

                    width: 900

                }

            });

        }



GD Gobinath Dhamotharan Syncfusion Team March 6, 2023 01:22 PM UTC

We modified a sample to achieve your requirement. By giving multipage as true we can print the overall diagram content in multiPages. Refer to the sample and documentation for your reference.

Code snippet

  diagram.printImage(JsonContent.responseText, {

      fileName: "diagram",

mode: "Data",

format: "png",

 multiplePage : true,

 region: "PageSettings",

stretch: "Meet", pageHeight: 700, pageWidth: 500,

bounds: { x: 0, y: 0, height: 1600, width: 500 }

   });


Documentation

https://ej2.syncfusion.com/aspnetmvc/documentation/diagram/export#print

Sample


Attachment: HTML_to_PDF_49a692ff_fbf93858.zip


SD Sourangsu Dasgupta replied to Gobinath Dhamotharan March 10, 2023 01:32 PM UTC

is it possible to fit the image within single page horizontally? as of now I am keeping pageWidth and bound.width same , which is 500.

            diagram.printImage(returnData, {

                fileName: "diagram",

                mode: "Data",

                format: "png",

                multiplePage: true,

                region: "PageSettings",

                stretch: "Meet",

                pageHeight: Number(String(diagram.height).split('px')[0]),

                pageWidth: 500,

                pageOrientation: 'Portrait',

                bounds: {

                    x: 0,

                    y: 0,

                    height: printandExportAreaBound.height,

                    width: 500

                }

            });

so, part of the image gets clipped. But as soon as I increase page width and bound.width to 600 or 650, then extra portion of horizontal width moving to next page. We are not using any horizontal scroll so the entire diagram fits well inside the screen. Following dimension




Attached example of how the UI renders when width is (pagewidth, boundWidth ) 500,500 vs 600, 600. Objective is to fit the whole diagram horizontally within a page. 


Attachment: PageWidth_78b983c9.zip


GD Gobinath Dhamotharan Syncfusion Team March 13, 2023 03:28 PM UTC

We will  validate and update you with more details on March 15,2023.



GD Gobinath Dhamotharan Syncfusion Team March 14, 2023 02:46 PM UTC

We modified a sample to your requirement. Use the content for region option in the printImage function to print huge diagrams to fit within the page horizontally. Refer to the sample below for your reference.

Code snippet

diagram.printImage(JsonContent.responseText, {

                        fileName: "diagram", mode: "Data", multiplePage: false, region: "Content", bounds: { x: 0, y: 0, height: size.height, width: size.width}

                    });



Attachment: print_and_export_451f9d69.zip

Loader.
Live Chat Icon For mobile
Up arrow icon