0

I want to use custom, external CSS file when converting my ASP.NET MVC page to pdf using EvoPDF library. I don't see anywhere any Styles property that indicates it could be done, is it possible? Do you know any workaround to have specific CSS styles only for conversion using EvoPdf?

2 Answers 2

1

You could use the CSS @media rule to target only a certain mediatype. You could then set the mediatype of the rendered HTML using EvoPDF:

var pdfConverter = new HtmlToPdfConverter(serverIp, serverPort)
        {
            MediaType = "evopdf"
        };
Sign up to request clarification or add additional context in comments.

Comments

0

I have an automatic process to create a Style.cshtml file which is a partial injected into the default layout.

var gulp = require('gulp'),
fs = require('fs'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
gap = require('gulp-insert');

gulp.task('default', function () {
     return gulp.src("Content/main.scss")
         .pipe(sass())
         .pipe(rename("_style.cshtml"))
         .pipe(gap.wrap("<style>\n", "</style>"))
         .pipe(gap.transform(function (contents, file) {
          // Prevent @Fontface etc from causing errors
          return contents.replace(/@/g, "@@");
          }))
          .pipe(gulp.dest("Views/Shared/"));
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.