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?
Asked
Active
Viewed 852 times
2 Answers
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"
};

Cameron Lattz
- 83
- 8
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/"));
});

EddyHaigh
- 13
- 1
- 5