Welcome Guest Search | Active Topics | Sign In | Register

Print->Landscape is not working Options
serializer
Posted: Wednesday, February 19, 2020 7:27:15 AM
Rank: Advanced Member
Groups: Member

Joined: 5/9/2016
Posts: 84
Since some builds I can no longer print in Landscape mode - it is always coming out in Portrait mode.

I have tried setting both these to landscape mode (not sure which one should be used):

pgs.PrinterSettings.DefaultPageSettings.Landscape = True
pgs.Landscape = True

Here is the full code:

Quote:
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Before SyncLock - " & psc.File, TaskProcess)
End If
SyncLock objPrintLock
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Start", TaskProcess)
End If
'Create objects for printer and page settings and PrintDocument
AddHandler EO.Base.Runtime.Exception, AddressOf EOException

Dim ps As New System.Drawing.Printing.PrinterSettings()

Dim pgs As New System.Drawing.Printing.PageSettings()

pgs.Margins = New System.Drawing.Printing.Margins(psc.MarginLeft, psc.MarginRight, psc.MarginTop, psc.MarginBottom)

' print range
Select Case psc.PrintRange
Case EnmPrintRange.AllPages
' do nothing
Case EnmPrintRange.CurrentPage
pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.CurrentPage
Case EnmPrintRange.Selection
pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection
Case EnmPrintRange.SomePages
pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection
End Select


If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Setting printer: " & psc.SelectedPrinter, TaskProcess)
End If
'Set printer name
ps.PrinterName = psc.SelectedPrinter

'Set PageMargins (if required)
ps.DefaultPageSettings.Margins.Left = psc.MarginLeft
ps.DefaultPageSettings.Margins.Right = psc.MarginRight
ps.DefaultPageSettings.Margins.Top = psc.MarginTop
ps.DefaultPageSettings.Margins.Bottom = psc.MarginBottom

' copies
ps.Copies = psc.NoOfCopies
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Adding printer settings", TaskProcess)
End If
pgs.PrinterSettings = ps

Dim pdfdoc As New PdfDocument(psc.File, psc.Password)

' add support for printing specific pages
If psc.SelectedPages IsNot Nothing Then
Dim selectedPages As String = GetSelectedPages(psc.SelectedPages)
Dim pages() As String = selectedPages.Split(",".ToCharArray)

' create integer list of pages to print
Dim intPagesToPrint As New List(Of Integer)
For Each strPage As String In pages
intPagesToPrint.Add(CInt(strPage))
Next

' create list of pdf pages to remove
Dim lstRemovePages As New List(Of PdfPage)
Dim i As Integer = 1
For Each pdfPage As PdfPage In pdfdoc.Pages
If Not intPagesToPrint.Contains(i) Then
lstRemovePages.Add(pdfPage)
End If
i += 1
Next

' remove pages from document
For Each pdfPage As PdfPage In lstRemovePages
pdfdoc.Pages.Remove(pdfPage)
Next
End If

Dim IsLandscape As Boolean = False
If pdfdoc.Pages.Count > 0 Then
IsLandscape = pdfdoc.Pages(0).Size.Width > pdfdoc.Pages(0).Size.Height
End If

Select Case psc.PageSettings.PaperOrientation
Case EnmOrientation.Landscape
pgs.PrinterSettings.DefaultPageSettings.Landscape = True
pgs.Landscape = True
Case EnmOrientation.Portrait
pgs.PrinterSettings.DefaultPageSettings.Landscape = False
pgs.Landscape = True
Case EnmOrientation.Auto
pgs.PrinterSettings.DefaultPageSettings.Landscape = IsLandscape
pgs.Landscape = IsLandscape
End Select

If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Before sending print", TaskProcess)
End If

mt = pdfdoc.Print(ps, pgs)
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->After sending print", TaskProcess)
End If
mt.WaitOne()


If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->After mt.WaitOne", TaskProcess)
End If
RemoveHandler EO.Base.Runtime.Exception, AddressOf EOException
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Removing exception", TaskProcess)
End If
End SyncLock
If TaskProcess.Task.TaskDebugging Then
LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->After SyncLock - " & psc.File, TaskProcess)
End If
eo_support
Posted: Saturday, February 22, 2020 1:21:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

We have looked into this issue. Internally we use the Chromium browser engine's PDF plugin to load/print PDF file. However printing orientation for plugin is not supported by the browser engine. If you load a PDF file in Google Chrome browser and try to print it, you will see that there is no orientation option in the print setting dialog.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.