Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Aug 14, 2017 7:41 pm

Hello and thank you in advance for your help!
My company (Wespath Benefits and Investments) already has a license for Spire.PDF and Spire.Excel. I am trying to use it, but ran into few issues.

1. I was using Spire.PDF conversion process to convert HTML to PDF, but quality of the PDF text does not satisfactory for us. The text is blurry and kinds of out of focus. So this is my first issue. Any suggestions? Here is my code using Spire.PDF.dll.
Dim pdfDoc As New PdfDocument
Dim pdfSetting As New PdfPageSettings
Dim pdfFormat As New HtmlConverter.PdfHtmlLayoutFormat
pdfDoc.CompressionLevel = PdfCompressionLevel.BestSpeed
pdfDoc.DocumentInformation.Author = "Wespath "
pdfDoc.UseHighQualityImage = True
pdfFormat.Layout = Graphics.PdfLayoutType.Paginate
pdfFormat.FitToPage = HtmlConverter.Clip.Both
pdfSetting.Size = PdfPageSize.Letter
pdfSetting.Orientation = PdfPageOrientation.Portrait
pdfDoc.LoadFromHTML(strHTML, True, pdfSetting, pdfFormat)
pdfDoc.SaveToFile(PdfFileName, Spire.Pdf.FileFormat.PDF)
pdfDoc.Close()

2. I read some of your articles and switches to Spire.Doc.dll instead. The quality of the pdf is MUCH better, but I have few issues with this too.

a. If we decided to go with it, we will buy the license, but can I get a temporary license so I can test it without warning message on the top?

b. Some HTML tags are not recognized by Spire.Doc.dll. For example: <hr> is not converted at all; <table> tag ‘style’ is not recognized till I wrap <table> with <p> tags. Any suggestions?

c. And last one  Is there a way to change a page number (in red below) font/size? I only found it for header/footer, but not for a page number. Here is my code.

Using Spire.Doc
Using Spire.Doc.Documents
Dim doc As New Document()
Dim sec As Section
Dim footer As HeaderFooter
Dim footerParagraph As Paragraph
Dim par As Spire.Doc.Documents.Paragraph

doc.BuiltinDocumentProperties.Company = "Wespath"
sec = doc.AddSection
sec.PageSetup.Orientation = PageOrientation.Portrait
sec.PageSetup.PageSize = PageSize.Letter
par = sec.AddParagraph()

footer = sec.HeadersFooters.Footer
footerParagraph = footer.AddParagraph()
footerParagraph.AppendText(" Page ")
footerParagraph.AppendField("page number", FieldType.FieldPage)
footerParagraph.AppendText(" of ")
footerParagraph.AppendField("number of pages", FieldType.FieldNumPages)
footerParagraph.Format.HorizontalAlignment = Documents.HorizontalAlignment.Right
par.AppendHTML(strHTML)
doc.SaveToFile(PdfFileName, Spire.Doc.FileFormat.PDF)
doc.Close()

Tanya Lerner
(847) 866-4329
tlerner@wespath.org

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Tue Aug 15, 2017 2:49 am

Hello,

Thanks for your inquiry. Below are the anwsers to your questions.
1. You could try another method which works much better, that is converting html to pdf with new plugin.
2. Yes, Spire.Doc can also be a good choice.
a. Our sales team will send the temporary license for Spire.Office to you ASAP.
b. I have noticed that the <hr> tag didn't make sense and referred it to our dev team. However, the css style in <table> could be well recognized on my side. I will attach my testing code together with point c.
c. Please use the code below to change the font family and font size for the page number.
Code: Select all
Dim doc As New Document()
Dim sec As Section = Nothing
Dim footer As HeaderFooter = Nothing
Dim footerParagraph As Paragraph = Nothing
Dim par As Spire.Doc.Documents.Paragraph = Nothing

doc.BuiltinDocumentProperties.Company = "Wespath"
sec = doc.AddSection()
sec.PageSetup.Orientation = PageOrientation.Portrait
sec.PageSetup.PageSize = PageSize.Letter
par = sec.AddParagraph()
//instantiate a chatacter format object and set the font size and family as well as the color
Dim cf As New CharacterFormat(doc)
cf.Font = New Font("Arial", 22)
cf.TextColor = Color.Red

footer = sec.HeadersFooters.Footer
footerParagraph = footer.AddParagraph()
footerParagraph.AppendText(" Page ")
Dim field As Field = footerParagraph.AppendField("page number", FieldType.FieldPage)
''Apply the character format
field.ApplyCharacterFormat(cf)

footerParagraph.AppendText(" of ")
footerParagraph.AppendField("number of pages", FieldType.FieldNumPages)
footerParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right

Dim strHTML As String = "<table style='color:green;font-weight:bold;' border='1'>" + "<tr>" + "<th>Month</th>" + "<th>Savings</th>" + "</tr>" + "<tr>" + "<td>January</td>" + "<td>$100</td>" + "</tr>" + "</table>"
par.AppendHTML(strHTML)
doc.SaveToFile("11366.pdf", FileFormat.PDF);
doc.Close()


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue Aug 15, 2017 2:47 pm

Thanks a lot for your quick response!
I tried to apply the font/color to the page number information, but have a weid result.
The output is following 'Page 1 of 2'. The font/size was applied but only for 'Page .. of 2'. The '1' is still in a bigger size. So 'FieldNumPages' works, but 'FieldPage' does not. Thank you in advance!

Here is the code that I have


''instantiate a chatacter format object and set the font size and family as well as the color
Dim text As Spire.Doc.Fields.TextRange
Dim field As Spire.Doc.Fields.Field
Dim cf As New Spire.Doc.Formatting.CharacterFormat(doc)
cf.Font = New Drawing.Font("Arial", 8)
cf.TextColor = Drawing.Color.Black

''build footer page number info
footer = sec.HeadersFooters.Footer
footerParagraph = footer.AddParagraph()

text = footerParagraph.AppendText(" Page ")
field = footerParagraph.AppendField("page number", Spire.Doc.FieldType.FieldPage)
field.ApplyCharacterFormat(cf)
text.ApplyCharacterFormat(cf)
text = footerParagraph.AppendText(" of ")
field = footerParagraph.AppendField("number of pages", Spire.Doc.FieldType.FieldNumPages)
field.ApplyCharacterFormat(cf)
text.ApplyCharacterFormat(cf)

footerParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Tue Aug 15, 2017 4:21 pm

One more question :)

The following html table style does not work when converted to pdf using Spire.Doc.dll. Actually, it does apply color, but not the size.
The style conversion works for Spire.PDF.dll, but we'd like to use Spire.Doc.dll b/c it has better quality. So currently I have ~50 forms that have imbedded html table with styles and the convertion does not works for those. Any suggestions... Let me know if you need more info.

<table style="width:100%;font-family:Arial; font-size:xx-small; color:Gray;">
<tr>
<td style="width: 90%;">&copy; 2016, Wespath Benefits and Investments</td>
<td style="width: 10%; text-align: right;">FM225</td>
</tr>
</table>

Thank you,
Tanya Lerner

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Wed Aug 16, 2017 3:29 am

Hello,

Thanks for your feedbak.
After an initial test with the latest version(Spire.Office Platinum Version:2.16), I didn't encounter the font size issue for the 'FieldPage". Please use the latest version to check again. If the issue still troubles you, please share more details.
As for the second "font-size" table style issue, I have reproduced it and referred to our dev team. Once there's any update, I will let you know.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Aug 16, 2017 1:35 pm

Thank you! Are the dlls from 'Spire.Office Platinum Version:2.16' will work on 32 bit machine? Can I use the same .dlls for 32 bit machine as for 64? We are currently developing on 32 bit machine, but will be migrating to 64 bit by the end of the year.

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Thu Aug 17, 2017 1:42 am

Hello,

Thanks for your response.
Yes, you can use the same .dlls for both the 32bit and the 64bit machine because the computer system bit has no influence on the dll appliance.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu Nov 30, 2017 3:40 am

Hello Tanya Lerner,

Glad to inform that the "hr" tag issue has been resolved and the hotfix Spire.Doc Pack(hot fix) Version:6.0.63 is available now. I'll inform you again when the hotfix for Spire.Office is released.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Sun Feb 11, 2018 8:20 am

Hello,

Now the Spire.Office Platinum (DLL Only) Version:2.16.27 has been released. As for the font-size issue, we are still investigating it.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Fri Mar 23, 2018 6:05 pm

Hello and thanks a lot for all your help. My company just bought Spire.Office (I am waiting for the license key right now). I downloaded the latest Spire.Office version and trying to process our documents. Here are few issues that I ran into:

1. some of the variables are decomissioned with newer version of the Spire.Office and I cannot make them work (see attachment 1).
2. spire.Doc has much better quality conversion that spire.PDF (we knew about this already), so I use spire.Doc.dll. However spacing does not work with spire.doc.dll as I expect. Specifically when there is HTML tags <b><br/>, the break does not work.
3. I also cannot make page break work as well with spire.doc.dll. However it works with spire.pdf.dll.

I really like the conversion quality of doc.dll, but layout is not converted the way that I expect (layout works with pdf.dll however).

Tanya Lerner (Wespath)

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Mon Mar 26, 2018 6:56 am

Dear Tanya,

Thanks for your inquiry and sorry for late reply as weekend.
Answer 1, the variables you referred in the attachment have been obsoleted in the new version, please use the new method shown as below to continue your task.
Code: Select all
PdfDoc.PrintSettings.PaperSettings += delegate(Object sender, PdfPaperSettingsEventArgs e)
'Get the paper source trays collection
Dim sources() As System.Drawing.Printing.PaperSource=e.PaperSources
For i As Integer = 0 To sources.Length-1
    If sources(i).SourceName=strDrawer Then
          e.CurrentPaperSource=sources(i)
          Exit For
    End If
Next i

Answer 2, I used the latest Spire.Office Platinum (DLL Only) Version:2.16.27 to test the <br> tag, it worked well on my side, please share us with your input html string (or file) for testing.
Answer 3, is the page break you referred the style such as "page-break-after: always;" in html file? I tested the styles, they performed correctly as well. Please provide your input example to help us do investigations.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Mar 26, 2018 8:20 pm

Thank you for your reply.
We are in the process of converting our current system that has ~100 forms. Those forms are in HTML format and get converted to PDF using 3rd party dll. We'd like to replace that dll with your Doc.DLL. However the pdf output layout has some issues. You can identify them by comparing original .pdf with newly converted .pdf (specifically line breaks: in some cases there is one when expected more and vice versa; page break does not happen where expected; margins are not recognized; etc...). It's very much possible that my code needs to be modified.

I am attaching following files:
Original.pdf - pdf converted using 3rd party .dll
Spire.Doc.DLL.pdf - pdf converted using Spire Doc.dll
HTML.docx - html which is used for conversion
conversionCode.docx - feel free to make any changed and let us know :)

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Tue Mar 27, 2018 6:39 am

Hello,

Thank for your provide detailed information.
After testing your html file, I indeed found the <br> tag as well as the page break ( page-break-before:always ) issues on my side. But I can't found the margin issue, is it referring to the style (margin-bottom:10px)? It worked well at my end (please refer to the attached picture). I have posted the <br> tag issue to our dev team for fixing, if there is any good news, we will let you know. I have noticed that the <a style="page-break-before: always; width:95%" /> is contained in table tag , in fact, inserting a page break into a table is against the standard of MS Word, hence the page break style didn't work. BTW, if you move the html content out of the two outside tables, the page break and <br> tag issues will disappear. Maybe this can be a soultion for you.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Tue Apr 03, 2018 9:39 pm

Thanks a lot for your response. It was very helpful. I had to modify some html tags to make it work. Majority of the issues are resolved!!
Here is one more thing that maybe you can help me with. On some pages I use <p style="display:inline"> or <p style="display:none">. However when I have 'display:none', the pdf still has a blank in the place where paragraph is display:none. I am attaching the example. Let me know if you have more questions.
Thanks a lot for all your help!

tlerner
 
Posts: 32
Joined: Mon Aug 14, 2017 5:49 pm

Wed Apr 04, 2018 2:43 am

Dear Tanya,

Thanks for your feedback.
I have noticed the issue you reported and submitted it to our Dev team for investigating and fixing. When it is fixed or there are some updates for you, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc