Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue May 03, 2016 6:05 pm

I just downloaded and installed Spire.PDF and have added references in my project for the dlls. In my script task I have created code to create pdf files from txt files and there are no obvious errors (squiggly lines) showing up in the task script itself. However when I run the package as soon as it gets to any of the Spire class references, I get an error stating "Exception has been thrown by the target of an invocation." Did I miss a step somewhere? Do I need to register the dll for use in VS?

The first line that fails is "Dim fileDoc As New PdfDocument()".

Code: Select all
Dim strText As String = File.ReadAllText(Dts.Variables("User::filePath").Value.ToString)
        Dim filePDF As String = Dts.Variables("User::filePath").Value.ToString.Replace(".txt", ".pdf")
        Dim fileDoc As New PdfDocument()
        Dim fileSection As PdfSection = fileDoc.Sections.Add()
        Dim filePage As PdfPageBase = fileSection.Pages.Add()
        Dim fileFont As PdfFont = New PdfFont(PdfFontFamily.Helvetica, 11)
        Dim fileFormat As PdfStringFormat = New PdfStringFormat()
        fileFormat.LineSpacing = 20.0F
        Dim fileBrush As PdfBrush = PdfBrushes.Black
        Dim textWidget As PdfTextWidget = New PdfTextWidget(strText, fileFont, fileBrush)
        Dim y As Single = 0
        Dim textLayout As PdfTextLayout = New PdfTextLayout()
        textLayout.Break = PdfLayoutBreakType.FitPage
        textLayout.Layout = PdfLayoutType.Paginate
        Dim textBounds As RectangleF = New RectangleF(New PointF(0, y), filePage.Canvas.ClientSize)
        textWidget.StringFormat = fileFormat
        textWidget.Draw(filePage, textBounds, textLayout)
        fileDoc.SaveToFile(filePDF, Spire.Pdf.FileFormat.PDF)


Thanks in advance for any assistance here.

[email protected]
 
Posts: 1
Joined: Tue May 03, 2016 2:44 pm

Wed May 04, 2016 3:44 am

Dear Russell,

Thanks for your inquiry.
Please try to register the dlls into GAC. If there still is issue, welcome to get it back to us.

Best Regards,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.PDF