Hi Sowmiya,
OS: Win10
Display: 2k monitors + 125%
SF Version : 17.2460.0.46
The file views, please note that the image in the pdf file appears like it's being cropped to the total space of the logo in the xaml file:
XPS FILE |
|
PDF File |
|
The main part of the code, tempFile is the path to the temporary XPS file:
//GET XAML file as XPS
var p = printFrame as FixedPage;
pageFrame.Child = null;
if (p == null) {
throw new Exception("Page is null."); }
var xpsFile = GetXPSDocumentAsStream(p, ref tempFile);
if (xpsFile != null) {
xpsFile.Position = 0;
//writeXPSToFile(ref xpsFile, filePath);
Syncfusion.XPS.XPSToPdfConverter converter = new Syncfusion.XPS.XPSToPdfConverter();
PdfDocument doc = converter.Convert(tempFile);
//doc.PageSettings.Size = PdfPageSize.A4;
//doc.PageSettings.Orientation = PdfPageOrientation.Portrait;
doc.Save(filePath);
//open PDF file
System.Diagnostics.Process.Start(filePath);
doc.Close(); }
The part that saves the pdf:
try {
MemoryStream output = new MemoryStream();
var doc = new FixedDocument();
var pContent = new PageContent();
content.Width = 2000;
content.Height = 2900;
((System.Windows.Markup.IAddChild)pContent).AddChild(content);
doc.Pages.Add(pContent);
if (overdue) {
pContent = new PageContent();
var temp = new FixedPage();
temp.Width = 2000;
temp.Height = 2900;
temp.Children.Add(new OverdueDetails());
((System.Windows.Markup.IAddChild)pContent).AddChild(temp);
doc.Pages.Add(pContent); }
//var xDoc = new XpsDocument(System.IO.Packaging.Package.Open(output, FileMode.Create, FileAccess.ReadWrite));
var xDoc = new XpsDocument(tempFile, FileAccess.ReadWrite, System.IO.Packaging.CompressionOption.NotCompressed);
var xpsWriter = XpsDocument.CreateXpsDocumentWriter(xDoc);
//write out doc
xpsWriter.Write(doc);
xDoc.Close();
return output; }
catch(Exception ex) {
gfuncs.ERROR(ref ex, "GetXPSDocumentAsStream", "PrintSavePDF");
return null; }
Attachment:
sample_files_d0775bdc.rar