SelectPdf Error : System.InvalidCastException: 'Conversion from string "" to type 'Integer' is not valid.'

71 Views Asked by At

I tried to merge two pdf using SelectPdf library. I used Vb.Net as language.It gave me an error like this

System.InvalidCastException: 'Conversion from string ""D:\PDF\1.pdf" to type 'Integer' is not valid.'

I did all the things after reading their references. Please help me to solve this problem.

 Public Sub MergePDF()
        
        Dim file1 As String = "D:\PDF\1.pdf"
        Dim file2 As String = "D:\PDF\2.pdf"

        ' load the 2 pdf documents
        Dim doc1 As New PdfDocument(file1)  //error generate here
        Dim doc2 As New PdfDocument(file2)

        ' create a new pdf document
        Dim doc As New PdfDocument()

        ' add the pages of those 2 documents to the new document
        doc.Append(doc1)
        doc.Append(doc2)

        ' save pdf document
        doc.Save(Response, False, "Sample.pdf")

        ' close pdf document
        doc.Close()

        ' close the original pdf documents
        doc1.Close()
        doc2.Close()
       
    End Sub
0

There are 0 best solutions below