Hi,
I am looking at the WordsProcessing to use in a project to convert HTML to PDF, however I have two issues. One the CSS from the linked files are not being applied so the first and easy question is must this be inline styles \ css in the cshtml file
The second is how do I get the output to show as landscape. My code below shows you how I am currently doing it and it is pushing out the HTML table and data but no styles from bootstrap (mentioned above) but its also very squashed so I need it to be in a landscape format.
public
byte
[] ConvertDocumentToPDF(
byte
[] fileData,
string
extension, ImageQuality exportQuality)
{
byte
[] convertedData =
null
;
RadFlowDocument document;
IFormatProvider<RadFlowDocument> provider =
this
.providers
.FirstOrDefault(p => p.SupportedExtensions
.Any(e =>
string
.Compare(extension, e, StringComparison.InvariantCultureIgnoreCase) == 0));
if
(provider ==
null
)
{
Log.Error($
"No provider found that supports the extension: {extension}"
);
return
null
;
}
try
{
using
(Stream stream =
new
MemoryStream(fileData))
{
try
{
document = provider.Import(stream);
}
catch
(Exception ex)
{
Log.Error(ex.ToString());
return
null
;
}
}
var quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Medium;
switch
(exportQuality)
{
case
ImageQuality.High:
quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.High;
break
;
case
ImageQuality.Medium:
quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Medium;
break
;
case
ImageQuality.Low:
quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Low;
break
;
}
PdfFormatProvider formatProvider =
new
PdfFormatProvider();
formatProvider.ExportSettings.ImageQuality = quality;
using
(var stream =
new
MemoryStream())
{
formatProvider.Export(document, stream);
convertedData = stream.ToArray();
}
}
catch
(Exception ex)
{
Log.Error(ex.ToString());
}
return
convertedData;
}
Any and all help gratefully received.
Thanks