Page 1 of 1

Unable to change Sheet Size in VBExamples given in PDF-XChange 7 API

Posted: Wed Feb 20, 2019 5:19 pm
by gopinathrbe
Private Sub btnGo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnGo.Click
'Dim Printer As New Printer
'Dim D As Integer
'Dim P As Printer
Dim bVal As Boolean

PDFPrinter.ResetDefaults()
PDFPrinter.Option("Save.File") = fName.Text
PDFPrinter.Option("Save.SaveType") = "Save"
PDFPrinter.Option("Save.ShowSaveDialog") = "No"
PDFPrinter.Option("Save.WhenExists") = "Overwrite"

'''Added by user
PDFPrinter.Option("Paper.SheetSizeIndex") = 11

'''Added by user
'PDFPrinter.Option("Paper.SheetSizeIndex") = -2
'PDFPrinter.Option("Paper.SheetWidth") = 3000
'PDFPrinter.Option("Paper.SheetHeight") = 4000


bVal = doCompress.CheckState
If (bVal = True) Then
With PDFPrinter
.Option("Compression.Graphics") = "Yes"
.Option("Compression.Text") = "Yes"
.Option("Compression.ASCII") = "No"
.Option("Compression.Color.Enabled") = "Yes"
.Option("Compression.Color.Method") = "Auto"
.Option("Compression.Indexed.Enabled") = "Yes"
.Option("Compression.Indexed.Method") = "Auto"
.Option("Compression.Mono.Enabled") = "Yes"
.Option("Compression.Mono.Method") = "Auto"
End With
Else
PDFPrinter.Option("Compression.Graphics") = "No"
PDFPrinter.Option("Compression.Text") = "No"
End If
bVal = doEmbedd.CheckState
PDFPrinter.Option("Fonts.EmbedAll") = IIf(bVal = True, 1, 0)
bVal = doRun.CheckState
PDFPrinter.Option("Save.RunApp") = bVal
If bVal = True Then
PDFPrinter.Option("Save.RunCustom") = "No"
End If

' To Hide progress window uncomment the next line
PDFPrinter.Option("Saver.ShowProgress") = "No"

'''Added by user
PDFPrinter.ApplyOptions(0)





If (TabControl1.SelectedTab.Name = "TabPage3") Then
IE_WebBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER)
ElseIf (TabControl1.SelectedTab.Name = "TabPage2") Then
ShellExecute(0, "printto", m_File.Text, """" & pname & """", CStr(VariantType.Null), SW_MINIMIZE)
ElseIf (TabControl1.SelectedTab.Name = "TabPage1") Then
PDFPrinter.SetAsDefaultPrinter()

Dim printDoc As New PrintDocument
AddHandler printDoc.PrintPage, AddressOf Me.printDoc_PrintPage
printDoc.Print()


'PDFPrinter.RestoreDefaultPrinter()
' For Each P In Printers
' If P.DeviceName = pname Then
' ' Set printer as default for current session
' Printer = P
' ' Stop looking for a printer
' Exit For
' End If
' Next P
' '
' 'initialize printer
' D = Printer.TwipsPerPixelX
' Printer.Orientation = PrinterObjectConstants.vbPRORPortrait
' 'initialized
' Printer.FontName = "Arial"
' Printer.FontSize = 12
' Printer.CurrentX = 1000
' Printer.CurrentY = 3000
' Printer.Print("Sample printing from VB using PDF-XChange V6")
' Printer.Circle(3745, 3000, 2900)
' Printer.NewPage()
' Printer.EndDoc()
End If
End Sub