I have simple WPF application I created in MS Visual Studio 2017 as a test to convert XLSX to PDF.
This example works fine if my Desktop resolution is 100%. But In case if I chane Desktop resolution to 200% (because I have 4K monitor), output PDF file looks poor.
In attached ZIP file you can see source XLS file, PDF files I created with 200% resolution and 100% resolution. My test project is also an attachment.
So, my question is: what should I do to let my WPF applications work with any Desktop resolution value? Because the same code works well if I put it into Windows Forms Application I creave in the sane VS.
Please note, for rendering features (e.g. Excel to PDF, Sheet to image, etc.), Aspose.Cells only supports to render in 100% display settings. In other display settings, you might not get proper/perfect results.
You may specify the DPI at the start of your program in code for your requirements:
e.g. Sample code:
.......
CellsHelper.DPI = 96 'This should be first line and before your actual code and it will be equal to 100% display settings of your os/machine.
'........
'your code goes here.
'.......
Using the above line will ensure to get the same results (for output PDF/image) as you could generate (Save as PDF) in “100%” display settings.
I test youred shared project on a 125% resolution Desktop env with CellsHelper.DPI = 96 set on the same place as your screenshot highlighted, it works OK.
Please try to log CellsHelper.DPI after you set CellsHelper.DPI = 96 to see whether CellsHelper.DPI is set successfully on your 200% resolution Desktop env.
CellsHelper.DPI is only allowed to be set once. Please don’t add CellsHelper.DPI in watch window. It may be init before you set it in Debug model.
Please try to log it(e.g. log to a file) after you set CellsHelper.DPI = 96, and directly run the project(Start Without Debugging).
Please notice, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found printing Excel file renders two pages instead of one page. I have logged a ticket with an id “CELLSNET-50063” for your issue. We will look into it soon.
Once we have an update on it, we will let you know.
I’d like to define duplex mode, copies number and print job name. Unfortunately, defining print job name doesn’t work. My code snippet is below.
Cold you please tell me how can I solve this task?
…
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
SetLicense()
Dim sSrcFile = "D:\fGI Proekts -- Mike version\Code Examples\VB solutions\Aspose.Cells test\1Master.xlsx"
Dim sPrinterName = "Canon iR C3000 Series UFR II" ' "Microsoft Print to PDF"
Try
Using excelDoc = New Workbook(sSrcFile)
Dim ro As New Rendering.ImageOrPrintOptions() With {
.PrintingPage = PrintingPageType.Default,
.PageIndex = 1, ' start from 2-nd page
.PageCount = 2, ' and print pages 2 and 3
.PrintWithStatusDialog = False
}
Dim activeSheet = excelDoc.Worksheets(excelDoc.Worksheets.ActiveSheetIndex)
Dim sr = New Rendering.SheetRender(activeSheet, ro)
Dim ps As New Printing.PrinterSettings() With {
.PrinterName = sPrinterName,
.PrintFileName = GetFileNameExt(sSrcFile),
.Copies = 2,
.Collate = True,
.Duplex = Printing.Duplex.Vertical
}
sr.ToPrinter(ps) ' Unable to define Print Job name here, as in this call: sr.ToPrinter(sPrinterName, GetFileNameExt(sSrcFile))
End Using
Catch ex As Exception
Console.WriteLine("Unable to process '" + sSrcFile + "'. Exception: " + ex.Message)
End Try
End Sub
We will check it but your issue/query does not seem to be related to Aspose.Cells APIs. I think you should browse internet and find respective forums for assistance.
We will add new API SheetRender.ToPrinter(PrinterSettings PrinterSettings, string jobName) .
I have logged a ticket with an id “CELLSNET-50088” for this feature.
Once we have an update on it, we will let you know.