Can someone tell me how can i export a docx document into pdf with password?
I tried the following but i get a corrupted pdf file:
RadFixedDocument documentFromPDFtmp = new RadFixedDocument();
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider providerFromPDFtmp = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
var fileFormatProvider = new DocxFormatProvider();
RadFlowDocument documentFromWord = fileFormatProvider.Import(sourceFile.InputStream); ;
IFormatProvider<RadFlowDocument> formatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (MemoryStream ms = new MemoryStream())
{
formatProvider.Export(documentFromWord, ms);
using (Stream stream = ms)
{
documentFromPDF = providerFromPDFtmp.Import(stream);
}
using (Stream output = new FileStream(path, FileMode.OpenOrCreate))
{
providerFromPDFtmp.ExportSettings.IsEncrypted = true;
providerFromPDFtmp.ExportSettings.UserPassword = Utils.GetConfigValue("PassPhrase");
providerFromPDFtmp.ExportSettings.ImageQuality = ImageQuality.Medium;
providerFromPDFtmp.Export(documentFromPDFtmp, output);
}
}
Looking forward for help with that
Thanks,
Hagai.