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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use PDF control in NodeJS environment

PDF control can be used in NodeJS environment by using EdgeJS. Please follow the steps below to achieve this.

  1. Create a new folder(CSharpToNodeJS).

 

  1. Open command prompt and install EdgeJS using npm.

npm install edge

 

 

  1. Create a new CS file as like below

Source.cs

 

using System.Threading.Tasks;

using System.Drawing;

using Syncfusion.Pdf;

using Syncfusion.Pdf.Graphics;

 

namespace Source

{

    public class Startup

    {

        public async Task<object> Invoke(object outputPath)

        {

            //Create new PDF document

            PdfDocument doc = new PdfDocument();

            //Add new page to the PDF document

            PdfPage page = doc.Pages.Add();

            //Draw a string to the page

            page.Graphics.DrawString("Hello World from .Net",

                new PdfStandardFont(PdfFontFamily.TimesRoman, 10),

                PdfBrushes.Black,

                new PointF(100, 100));

            //Save and close the document

            doc.Save(outputPath as string);

            doc.Close(true);

            return "PDF generated successfully..!";

        }

    }

}

 

 

  1. Create new JS file as like below.

Sample.js

 

var edge = require('edge');

 

var CreatePDF = edge.func('Source.dll');

 

CreatePDF("Output.pdf", function (error, result) {

    if (error) throw error;

    console.log(result);

});

 

 

  1. Place the below required assemblies in the project folder(CSharpToNodeJS)
  1. Syncfusion.Compression.Base.dll
  2. Syncfusion.Pdf.Base.dll

  1. Open the command prompt and build the cs file with the necessary reference by using the below command.

"C:\Windows\Microsoft.NET\Framework\vx.x.xx\csc.exe" /r:Syncfusion.Compression.Base.dll,Syncfusion.Pdf.Base.dll,System.Drawing.dll /target:library /debug Source.cs

 

 

  1. Once the command succeed Source.dll will be generated as like below.

  1. Run the below code in command prompt to run the C# code with NodeJS.

node Sample.js

 

 

Please find the attached sample for reference.

http://www.syncfusion.com/downloads/support/directtrac/general/ze/CSharpToNodeJS-735846718

Article ID: Published Date: Last Revised Date: Platform: Control:
7178 12/22/2016 12/22/2016 WinForms PDF
Tags:
pdf
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon