It seems, that Aspose.Words prints 1-st page of my DOCX file incorrectly. This page size should have “Envelope No. 10” size, but Aspose.Words prints it as “A4”.
Just for experiment, I used Aspose.Words to save this DOCX file as PDF and output PDF page size is correct.
My code snippet is below.
The source DOCX file and two screenshot image are an attachment.
Please let me know if you are able to fixe this issue soon.
Dim sFile = "C:\Users\Mikhael\Desktop\Casey Newsom\1032034.docx"
Dim sPrinter = "Canon iR C3000 Series UFR II"
Try
Dim myDoc As New Aspose.Words.Document(sFile)
myDoc.Save("D:\out\1032034.pdf", Words.SaveFormat.Pdf)
Dim ps As New System.Drawing.Printing.PrinterSettings() With {.PrinterName = sPrinter}
myDoc.Print(ps, GetFileNameExt(sFile))
Catch ex As Exception
End Try
@Mikhael You should use PageSetup.FirstPageTray and PageSetup.OtherPagesTray properties to specify which paper source should be used for the first and other pages in sections.
In your document paper tray is not specified and the default one is used.
If I use my code snippet to print DOCX fil I attached, 1-st page is printed on A4, and 2-nd - on Letter page. So, it seems, that Aspose.Words selected printed page size automatically without PageSetup.FirstPageTray and PageSetup.OtherPagesTray properties usage.
The same output paper size autodetection happened if I use Microsoft Word 2019 to print this file.
The only one difference: MS Word detects 1-st page size correctly, but Aspose.Words – incerrectly.
I use “Auto” value for Paper source feature in my Canon iR C3000 Series UFR II printer driver settings panel.
Please let me know if I should share my printer driver distributive file to let you install it to try print files on this driver and see print preview. This ability can be used even if you not have this printer, connected to your computer.
Please follow this link to download my printer driver disctributive file: https://download.print-driver.com//ex/mb/Canon_imageRUNNER_C3025_GPlus_PCL6_Driver_V210_32_64_00.zip
Go to “Control panel->Devices and printers” and click “Add printer”
Click “Add a local printer or network printer with manual settings”, as you can see on the screenshot image below:
Select “FILE” as an existing port to be able to use a driver of the printer you do not connected to your computer:
Click “Have a disk” and then select “Cnp60MA64.INF” file you can find in folder “GPlus_PCL6_Driver_V210_32_64_00\x64\Driver”
Open printer preferences as soon as you finished printer driver installation.
Change “Edit and Preview” as output method value:
Please let me know if you are able to use my instruction to install and configure this printer driver and to be able to reproduce issue with page size detection I reported.
Alternatively I can assist you remotely to do this using Team Viewer software. Just let me know.
@Mikhael Thank you for additional information and the detailed guidelines. But, unfortunately, the problem is not reproducible on my side. Please see the screenshot of the document print preview: image.png (130.1 KB)
Also here is a .PRN file produced: out.zip (101.2 KB)
@alexey.noskov, I also use version 22.2 and my print preview looks as you can see on this screenshot image: image.png (338.6 KB)
Do you have any idea how can I make any log for you or what variables I can check to let you see what happened on my copmuter to let you advice me how should I change my code snippet?
I can start Team Viewer if you want to see what happened on my side. Just let me know.
@Mikhael Could you please run the following code on your side and share you output here;
Dim settings As New PrinterSettings()
settings.PrinterName = "Canon Generic Plus PCL6"
For i As Integer = 0 To settings.PaperSizes.Count - 1
Console.WriteLine(settings.PaperSizes(i))
Next
Console.WriteLine("====================================")
For i As Integer = 0 To settings.PaperSources.Count - 1
Console.WriteLine(settings.PaperSources(i))
Next
Console.WriteLine("====================================")
Dim doc As New Document("C:\Temp\in.docx")
For i As Integer = 0 To doc.PageCount - 1
Dim pageInfo As PageInfo = doc.GetPageInfo(i)
Console.WriteLine(pageInfo.GetDotNetPaperSize(settings.PaperSizes))
Console.WriteLine(pageInfo.GetSpecifiedPrinterPaperSource(settings.PaperSources, settings.DefaultPageSettings.PaperSource))
Console.WriteLine("---------------------------------")
Next
My code snippet and the output window content are below.
It seems, that printer driver I sent you and driver installed on my computer are different, because list of paper sizes your and my printer can use are different. So, shall I try find the same dreiver? Or we can use Team viewer to debug this issue on my computer?
Yes, I can use workaround for this issue: Aspose.Words is able to convert this DOCX to PDF correctly. After this I can use my code to print PDF. Unfortunately, performance of this tricky print is lower than direct printing DOCX file using Aspose.Words.
Plus, a customer, who uses printing solution I develop is also able to reproduce this issue…
Dim settings As New System.Drawing.Printing.PrinterSettings()
settings.PrinterName = "Canon iR C3000 Series UFR II"
Console.WriteLine("settings.PrinterName = " + settings.PrinterName)
For i As Integer = 0 To settings.PaperSizes.Count - 1
Console.WriteLine(settings.PaperSizes(i))
Next
Console.WriteLine("====================================")
For i As Integer = 0 To settings.PaperSources.Count - 1
Console.WriteLine(settings.PaperSources(i))
Next
Console.WriteLine("====================================")
Dim doc As New Words.Document("C:\Users\Mikhael\Desktop\Casey Newsom\1032034.docx")
Console.WriteLine("doc.OriginalFileName = " + doc.OriginalFileName)
For i As Integer = 0 To doc.PageCount - 1
Dim pageInfo As Words.Rendering.PageInfo = doc.GetPageInfo(i)
Console.WriteLine(pageInfo.GetDotNetPaperSize(settings.PaperSizes))
Console.WriteLine(pageInfo.GetSpecifiedPrinterPaperSource(settings.PaperSources, settings.DefaultPageSettings.PaperSource))
Console.WriteLine("---------------------------------")
Next
doc.Print(settings)
@Mikhael Thank you for additional information. I have managed to reproduce the problem with this driver. For a sake of correction the issue has been logged as WORDSNET-23505. We will keep you informed and let you know once it is resolved.