You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I am generating the pdf from razor partial view in asp.net core
the pdf is working fine but the style and format are not applied to the pdf
I am using bootstrap for styling and formatting the web pages
plz consider for my help
`
public async Task<byte[]> CreatePdf(PaperViewVM paperViewVM)
{
var view = await _renderer.RenderPartialToStringAsync("_PaperViewBoardLayout", paperViewVM);
string webRootPath = _webHostEnvironment.WebRootPath;
string PaperPath = webRootPath + WC.PaperPathPDF;
string guid = Guid.NewGuid().ToString();
string fileName = paperViewVM.Setting.SubjectName + guid;
string UniqueFileName = fileName + ".pdf";
var globalSettings = new GlobalSettings
{
ColorMode = ColorMode.Color,
Orientation = Orientation.Portrait,
PaperSize = PaperKind.A4,
DPI = 300,
ImageDPI = 900,
Margins = new MarginSettings() { Top = 10, Bottom = 10, Left = 10, Right = 10 },
Out = PaperPath + UniqueFileName,
};
var objectSettings = new ObjectSettings
{
PagesCount = true,
HtmlContent = view, // view is a html string from rendererhtmltostring method
WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "bootstrap.css") },
HeaderSettings = { FontName = "Arial", FontSize = 12, Line = true, Center = "Pdf Paper Generated by ExamSystem.com" },
FooterSettings = { FontName = "Arial", FontSize = 12, Line = true, Right = "Page [page] of [toPage]" }
};
var pdf = new HtmlToPdfDocument()
{
GlobalSettings = globalSettings,
Objects = { objectSettings }
};
byte[] file = _pdfConverter.Convert(pdf);
var obj = new GeneratedPaper();
obj.IsSuccess = true;
obj.PaperPath = WC.PaperPathPDF + UniqueFileName;
obj.CreatedBy = paperViewVM.Setting.CreatedBy;
obj.SubjectName = paperViewVM.Setting.SubjectName;
obj.CreateDate = DateTime.Now.Date;
return file;
}`
I tried to use bootstrap file for format reference but its not working
am i need to apply html formating styles on view for proper renderring the pdf
The text was updated successfully, but these errors were encountered:
Hi
I am generating the pdf from razor partial view in asp.net core
the pdf is working fine but the style and format are not applied to the pdf
I am using bootstrap for styling and formatting the web pages
plz consider for my help
`
I tried to use bootstrap file for format reference but its not working
am i need to apply html formating styles on view for proper renderring the pdf
The text was updated successfully, but these errors were encountered: