The following code works for an A4 page, but fails for the custom page size:
Dim PDFDocument As New Pdf
PDFDocument.PageSetup.PageWidth = 180
PDFDocument.PageSetup.PageHeight = 108
'Use the following 2 lines instead and it works!!
'PDFDocument.PageSetup.PageHeight = PageSize.A4Height
'PDFDocument.PageSetup.PageWidth = PageSize.A4Width
Dim PDFSection As New Section
PDFSection.PageInfo.PageWidth = PDFDocument.PageSetup.PageWidth
PDFSection.PageInfo.PageHeight = PDFDocument.PageSetup.PageHeight
Dim Graphics As New Graph(PDFSection)
With Graphics
.Margin.Top = 0
.PositioningType = PositioningType.PageRelative
.Left = 0
.Top = 0
.GraphWidth = PDFDocument.PageSetup.PageWidth
.GraphHeight = PDFDocument.PageSetup.PageHeight
End With
PDFSection.Paragraphs.Add(Graphics)
Dim NewRectangle As New Rectangle(Graphics)
With NewRectangle
.Left = 27
.Height = 20
.Bottom = 81
.Width = 152
.GraphInfo.Color = New Aspose.Pdf.Color("Black")
.GraphInfo.LineWidth = 2
End With
Graphics.Shapes.Add(NewRectangle)
PDFDocument.Sections.Add(PDFSection)
PDFDocument.Save("C:\temp.pdf")