SivaRajini
SivaRajini

Reputation: 7375

Angular JS parsing in pdf

Please refer below simple html with angular js code

<!doctype html>
<html ng-app>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
  </head>
  <body>
    <div ng-controller="MyCtrl">
  Hello, {{name}}!
</div>
<script type="text/javascript">

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
    $scope.name = 'Superhero';
}
</script>

  </body>
</html>

it will be working fine when i open this html in browser. but i want to export this html content to pdf.

Reading the all the contenats of html and writing the content in pdf file but angular js code is not parsed in pdf.

//reading the html content

string contents = File.ReadAllText(path);

//writing the html content to pdf

File.WriteAllText(path, contents);

but the output in pdf like

Hello, {{name}}!

that means it is not parsed in pdf. how to resolve this.

Note : i don't want to use some external plugin to generate the pdf for angular js code. i need to do in simple read and write in C#.

Upvotes: 1

Views: 944

Answers (1)

JoseM
JoseM

Reputation: 4302

The reason why you get that is because you are just reading the HTML response from the server, not the content that is actually generated after the Javascript on the page has been invoked.

You need to start up an instance of an actual browser that interprets the Javascript on the page, and then read the output from there. One API that you can try using is Selenium, I've used it from both Java and PHP applications but they also have a .NET client driver

Upvotes: 1

Related Questions