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.

Fri Sep 19, 2014 3:44 pm

hi,
I have a word document (which i attached) When I do a mail merge the font defaults to Arial. The code is below, thanks for any help.

Code: Select all
 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)

        Threading.Thread.Sleep(2000)

        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)
                iNoofPages = document.PageCount
                document.Close()

                RemoveHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage

            End If

        Catch ex As Exception
            WriteToEventLog("[CreateLetter] " + ex.Message, EventLogEntryType.Error, , )
        Finally

        End Try
        Return letterPath


Derek.

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

Mon Sep 22, 2014 7:08 am

Hello,

Sorry for late reply as weekend.
Sorry that we can't get any attachment here, please zip and attach it again.
Furthermore, if the fonts you use in the document aren't default fonts in the system, please firstly confirm the fonts are installed on the develop computer and try the following method.
Code: Select all
ToPdfParameterList embeddedFont = new ToPdfParameterList
            {
                IsEmbeddedAllFonts = true
            };
doc.SaveToFile("result.pdf", embeddedFont);

Sincerely,
Gary
E-iceblue support team
User avatar

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

Mon Sep 22, 2014 8:22 am

Have it attached, I'll try what you said thanks.

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

Mon Sep 22, 2014 8:51 am

Hello,

Thanks for your quick reply.
I check your document, there are some fonts aren't the system default fonts, so you need to install them in your computer and use the following method while saving doc to pdf.
Code: Select all
ToPdfParameterList embeddedFont = new ToPdfParameterList
            {
                IsEmbeddedAllFonts = true
            };
doc.SaveToFile("result.pdf", embeddedFont);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

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

Mon Sep 22, 2014 11:14 am

I have it fixed thanks, I just installed the fonts on the server.

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

Wed Sep 24, 2014 3:15 pm

Actually, it doesn't like Arial Narrow. Can you give me the full code fix that I posted earlier?

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

Thu Sep 25, 2014 2:44 am

Hello,

Thanks for your inquiry.
Please verify Arial Narrow font is installed in your compute. The following codes are for your reference.
Code: Select all
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)

        Threading.Thread.Sleep(2000)

        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

                Dim embeddedFont As ToPdfParameterList = New ToPdfParameterList
                embeddedFont.IsEmbeddedAllFonts = True
                document.SaveToFile(letterPath, embeddedFont)               
              iNoofPages = document.PageCount
                document.Close()

                RemoveHandler document.MailMerge.MergeImageField, AddressOf DoMergeImage

            End If

        Catch ex As Exception
            WriteToEventLog("[CreateLetter] " + ex.Message, EventLogEntryType.Error, , )
        Finally

        End Try
        Return letterPath

If the issue still arise, please send the output to us.
Sincerely,
Gary
E-iceblue support team
User avatar

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

Tue Sep 30, 2014 6:42 am

Dear derek,

Has your problem been resolved?
If not, please send more information to help us resolve it.

Best regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.PDF