Conversion issues when using Spire.Doc

Technical support for Spire.Doc

Moderator: iceblue support

Conversion issues when using Spire.Doc

Postby Leehk » Fri May 13, 2016 5:24 am

Hello team,

I'm using E-iceblue control (Spire.Doc for NET3.5) to develop a SharePoint webpart which has 2 main functions: Import a Word file to HTML then show its content into a Wiki page (*.aspx), export a Wiki page to PDF. There are some problems happened in my process.
1. For importing Word to HTML
1.1. Don't show the shapes in Word file (see Shapeslosing.rar)
1.2. If the Word file has page numbers, the HTML file also contains page numbers after importing. How can I remove that page numbers out of the HTML?.

2. For exporting HTML to PDF
2.1. An error occurred after exporting: "A generic error occurred in GDI+.". This is happened with some Wiki page which has lots of tables and bullets format (attached file GDI_Error.png)
2.2. Losing pages after exporting Wiki page to PDF (see Pageslosing.rar). Steps of the conversion: save a wiki page (imported from Word) to HTML then convert that HTML to PDF.
2.3. Losing the link after exporting HTML to PDF (see LosingLink.png)

Code: Select all
 private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    string tempPath = string.Format("{0}\\SPWiki\\Export", Path.GetTempPath());
                    WikiUtility.CreateFolderStoreHtmlContent(tempPath);
                    WikiUtility.SaveHtmlToLocalFile(itemUrl, tempPath, this.item.Name.Replace(".aspx", ".html"), currenSiteUrl);
                    string htmlFilePath = tempPath + "\\" + this.item.Name.Replace(".aspx", ".html");
                    this.document = new Document();
                    this.document.LoadFromFile(htmlFilePath, Spire.Doc.FileFormat.Html, XHTMLValidationType.None);
                    if (this.document != null)
                    {
                        GetConfigurationDoc();
                        using (Stream stream = new System.IO.MemoryStream())
                        {
                            document.SaveToStream(stream, Spire.Doc.FileFormat.PDF);
                            this.doc = new PdfDocument();
                            Thread thread1 = new Thread(() =>
                            { this.doc.LoadFromStream(stream); });
                            thread1.SetApartmentState(ApartmentState.STA);
                            thread1.Start();
                            thread1.Join();
                            if (this.chkInsertCurrentDate.Checked || this.chkInsertPageNumber.Checked)
                            {
                                DrawPageNumber(this.doc.Pages, this.doc.PageSettings.Margins, 1, doc.Pages.Count);
                            }
                            doc.SaveToHttpResponse(this.item.Name.Replace(".aspx", ".pdf"), HttpContext.Current.Response, HttpReadType.Save);
                        }
                        if (Directory.Exists(tempPath))
                            Directory.Delete(tempPath, true);
                    }
                });
            }
            catch (Exception ex)
            {
                this.DisplayErrors("btnSave_Click", ex);
            }
        }


Thank you in advance,
Lee K
You do not have the required permissions to view the files attached to this post.
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Fri May 13, 2016 7:00 am

Hi,

Thanks for your posting.
Regarding Word to HTML process,
1) sorry that we don't support to convert shape to HTML.
2) I tried to convert a word document has page numbers to HTML but the HTML file didn't contain page numbers.
Could you please share your document to help us replicate it? Thank you for your assistance.

Regarding Html to PDF process,
1) I tested converting the html to PDF by Spire.PDF API, and there were not the issues you encountered. I recommend you to use our Spire.PDF product to do the exported HTML to PDF conversion.
Here is a demo:
http://www.e-iceblue.com/Tutorials/Spir ... lugin.html

If you use Spire.Doc and Spire.PDF in same project, please download Spire.Office package and get the related dlls(Spire.Doc.dll, Spire.PDF.dll., Spire.License.dll) from it.

Please feel free to write us if you need further clarification or have further inquiry.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Fri May 13, 2016 9:32 am

hi Amy,

Thank you for the speedy reply!.

I attached a file that you can able to replicate the issue has page number in the HTML file.
I will try to use the Spire.Office package and let you know the result.

Thanks for your help,
Lee K
You do not have the required permissions to view the files attached to this post.
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Mon May 16, 2016 3:42 am

Hi,

Thanks for your further assistance.
Please use doc.HtmlExportOptions.HasHeadersFooters = false to remove page number in the HTML file.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Mon May 16, 2016 8:47 am

Hello Amy,

Thanks for your feedback.
The page number issue was resolved after using your given code.
To replicate the exporting HTML to PDF issues, I just have sent to you 3 VS projects by e-mail.

Thank you so much for your kindly support.
Lee K
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Mon May 16, 2016 9:28 am

Hi,

I have received your projects. Sorry for the inconvenience caused by our Spire.Doc products.
I recommand you to use our Spire.PDF product to convert your html files to PDF.
I have tested your html files with the following solution, and the output pdfs are fine. Please try it.
http://www.e-iceblue.com/Tutorials/Spir ... lugin.html

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Tue May 17, 2016 9:02 am

Hi,

Does the above solution resolve your issue?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Wed May 18, 2016 2:34 am

Hello Amy,

I tried to use Spire.Pdf (version 2.9.35.5040) from the HtmlToPdf.zip as your suggestion, the pdfs are fine after converting.

But when I use the converting HTML to PDF with new plugin, an error occurred in my project, I'm using Spire.Pdf (version 3.6.260.5035). VS project and plugins error image were sent to you by e-mail. I'm sure that the folder 'plugins' under the same folder of Spire.Pdf.dll, am I missing something here?.

Another question I would like to ask that if I deploy the Spire.Pdf.dll into the GAC (C:\windows\assembly\gac_msil), then how can I deploy the folder 'plugins' to make sure everything works fine?.

Thank you for your kindly support.
Lee K,
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Wed May 18, 2016 4:00 am

Hi,

I tested your project and it indeed had the issue. I checked the plugin and Spre.PDF.dll of your project and they were setted correctly. I created a winform project on my side. Please run it on your side to verify if it works.
http://www.e-iceblue.com/downloads/atta ... PDF518.zip

If deploying the Spire.Pdf.dll into the GAC, please use HtmlConverter.PluginPath to set the path of the plugins folder.
sample code:

Code: Select all
string outputFile = "C:\\output.pdf";
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = @"C:\amy\plugins";
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(input,
outputFile,
true,
10 * 1000,
new SizeF(612, 792),
new Spire.Pdf.Graphics.PdfMargins(0)
);


Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Wed May 18, 2016 4:20 am

Hi Amy,

I run your winform project on my side but the plugins error still happened. How can I resolve this issue?.

Thanks for your help.
Lee K
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby Gary.zhang » Wed May 18, 2016 6:58 am

Hello,

Thanks for your prompt response. You can try to the following method provided by other customer on the thread.
using-the-new-qt-htmlconverter-plugin-from-a-plugin-t5465-15.html
Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1388
Joined: Thu Apr 04, 2013 1:30 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Wed May 18, 2016 9:55 am

Hi Gary,

Thanks for your support.
I tried to install Visual C++ 2010 Redistributable Pkg x86 on my server (Windows Server 2008 R2 Standard) as the link that you suggested but the problem persists.

Thanks,
Lee K
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Thu May 19, 2016 3:55 am

Hi,

Please build your project as 32bit and then try again.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Re: Conversion issues when using Spire.Doc

Postby Leehk » Thu May 19, 2016 9:08 am

Hi Amy and Gary,

Thank you so much for your kindly support.
The project was built as 32bit but it didn't work too. Your winform project works fine after adding this line:
Code: Select all
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = @"C:\plugins";   


Currently, I am developing a SharePoint web part and the Spire.Pdf.dll was deployed into the GAC. I have tried some ways to set the path for plugins folder such as:
Code: Select all
HtmlConverter.PluginPath = context.Server.MapPath("~/bin/plugins");

Code: Select all
HtmlConverter.PluginPath = HttpContext.Current.Server.MapPath(@"..\bin\plugins");

Code: Select all
HtmlConverter.PluginPath = Context.Server.MapPath("/_layouts/15/BB/SPWiki/plugins");

and set "Enable 32-Bit Applications" to "true"
... but I always keep getting the error: The conversion provider cann't be found. Please make sure:
1. the folder "plugins" under the same folder of Spire.Pdf.dll
2. exists "plugins\HTMLConverter.dll" and other "plugins\*.dll

Could you please show me how to fix this issue?

Thanks in advance.
Lee K
Leehk
 
Posts: 39
Joined: Tue May 10, 2016 1:29 am

Re: Conversion issues when using Spire.Doc

Postby amy.zhao » Thu May 19, 2016 9:28 am

Hi,

Please check if it is 32 bit compatibility - integrated pipeline under Application Pool Settings.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2230
Joined: Wed Jun 27, 2012 8:50 am

Next

Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 1 guest