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.

Thu Jun 05, 2014 9:37 am

Hi, I append some PDFs together and I keep getting this error message:

at System.Collections.Generic.ObjectEqualityComparer`1.IndexOf(T[] array, T value, Int32 startIndex, Int32 count)
at System.Array.IndexOf[T](T[] array, T value, Int32 startIndex, Int32 count)
at System.Collections.Generic.List`1.IndexOf(T item)
at System.Collections.Generic.List`1.Remove(T item)
at ᣾.ᜄ(᡼ A_0)
at Spire.Pdf.Graphics.PdfTrueTypeFont.Dispose()
at Spire.Pdf.Graphics.PdfTrueTypeFont.Finalize()


I use this in a windows service.

Thanks,
Derek.

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Fri Jun 06, 2014 1:18 am

Hello,

Thanks for your feedback, please attach your Pdf files for our testing, which would be helpful to reproduce the issue and work out the solution for you ASAP.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jun 06, 2014 9:09 am

Hi,
The process is, we take a template document, do a mail merge for each customer and then append all the docs into a PDF.
The code to create the letter is:
Code: Select all
   Public Function CreateLetter(ByVal sLetterName As String, ByVal sReportId As String, ByVal sCreditors As String, ByVal sApplicationPath As String, ByVal iUserId As Integer) As String
        Dim sSQL As String
        Dim dsLetters As New DataSet
        Dim sFullLetter As String
        Dim letterPath = String.Empty
        sCreditors = sCreditors.Remove(0, 1)


        sSQL = "SP_PRINT_GROUPED_lETTERS '" + sCreditors.Remove(sCreditors.Length - 1, 1) + "'," + sReportId + "," + CStr(iUserId)
        sSQL = sSQL.Replace(Chr(34), " '")

        dsLetters = ReturnDataSet(sSQL)

        System.Threading.Thread.Sleep(5000)

        Dim dt As DataTable = ReturnDataTable(sSQL)

        'get template
        Dim sTemplateFile = dt.Rows(0)("TemplateFileName").ToString()
        If sTemplateFile.Length < 1 Then
            sTemplateFile = GetTemplateDoc(iUserId)
        End If

        Dim document As New Document(sApplicationPath + "Desktopmodules\AnnualReport\Uploads\" + CStr(iUserId) + "\" + sTemplateFile)

        Try
            If dsLetters IsNot Nothing Then

                AddHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage

                document.MailMerge.Execute(dt)
                sFullLetter = "\" + sLetterName + CStr(iUserId) + CStr(Now().Year) + CStr(Now().Month) + CStr(Now().Day) + CStr(Now().Minute) + CStr(Now().Second) + ".pdf"
                letterPath = sApplicationPath + "Desktopmodules\AnnualReport\Uploads\" + CStr(iUserId) + sFullLetter
                document.SaveToFile(letterPath, FileFormat.PDF)
                document.Close()

                RemoveHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage

            End If

        Catch ex As Exception
            MsgBox("Error" + ex.Message)
        Finally

        End Try
        Return letterPath
    End Function

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Fri Jun 06, 2014 9:37 am

Now I get Evaluation Warning : The document was created with Spire.Doc for .NET. Even though I have a license ?
Also, I get a 'Index is out of range error' Thanks for your help!

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Fri Jun 06, 2014 9:50 am

Hello,

Sorry that it is hard to locate the reason of the issue just according to your codes, could you please provide us you generates pdf files which are needs to merge? You can sent it to our Email(support@e-iceblue.com);

Regarding the Evaluation Warning, as your license file of Spire.Doc was expired on 2014-1-8. The one year subscription enables FREE hot fixes and new releases for 1 year. After the subscription expired, you can still use the product and deploy to your applications, only the hot fixes and new releases is no longer available. That's the reason why the warning message appear again.
You need to renew your license file to remove the warning message. We will offer 25% off discount for you to renew it. Please get back to us at sales@e-iceblue.com for coupon code.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jun 06, 2014 10:35 am

It crashes on this line:
Code: Select all
document.SaveToFile(letterPath, FileFormat.PDF)


If I save to docx it works fine. How can I convert a docx to PDF ?

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Mon Jun 09, 2014 1:38 am

Hello,

Sorry for late reply. Please provide us your template document for testing and the generated docx files .

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.PDF