vs2019 vb. net pdffilewriter.dll получает сообщение об ошибке - PullRequest
0 голосов
/ 22 января 2020

Я получаю

параметр недействительным

ошибка в методе Drawstring. все объекты имеют правильный тип и не являются нулевыми. ища тех, кто использовал pdfprint.dll. Я пробовал разные значения для rectanglef, предполагая, что проблема была вне пределов ошибки, но все еще не могу ее решить. DLL была написана в c#, но я не уверен, имеет ли это какое-либо отношение к этому или нет.

 Public Class PdfPrint
    Public cFont As Font
    Private PdfDoc As PdfDocument
    Private PageNo As Integer
    Public dr As DataTableReader
    Public Sub SavePDF(FileName As String)

        Dim printp As PdfPrintDocument
        Dim proc As Process
        PdfDoc = New PdfDocument(PaperType.Letter, False, UnitOfMeasure.Point, FileName)



        PageNo = 1
        printp = New PdfPrintDocument(PdfDoc)

        printp.Resolution = 300
        printp.SaveAs = SaveImageAs.BWImage
        printp.SetMargins(100, 100, 100, 100)
        AddHandler printp.PrintPage, AddressOf PrintPage

        printp.AddPagesToPdfDocument()
        printp.Dispose()
        PdfDoc.CreateFile()
        proc = New Process()

        proc.StartInfo = New ProcessStartInfo(FileName)
        proc.Start()





    End Sub




    Public Sub PrintPage(sender As Object, e As PrintPageEventArgs)

        Dim txt As String
        Dim g As Graphics



        ' Dim PrintArea As Rectangle
        '  Dim drawpoint As New RectangleF(e.MarginBounds.X + 4, e.MarginBounds.Y + 4, e.MarginBounds.Width - 8, 30)
        g = e.Graphics
        Dim drawpoint As New RectangleF(10, 10, 10, 10)


        ' Set everything to high quality
        g.SmoothingMode = SmoothingMode.HighQuality
        g.InterpolationMode = InterpolationMode.HighQualityBicubic
        g.PixelOffsetMode = PixelOffsetMode.HighQuality
        g.CompositingQuality = CompositingQuality.HighQuality
        g.DrawRectangle(Pens.Black, e.MarginBounds)
        ' print area within margins
        ' PrintArea = e.MarginBounds
        txt = "text"
        'parameter is not valid error below
        g.DrawString(txt, cFont, Brushes.Black, drawpoint)







    End Sub







End Class
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...