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 Apr 22, 2019 10:17 am

htmltopdf.zip
Hai When i am converting Html to Pdf more than 5mb It will take more than 5 minutes and that conversion also not Exact.

This is my code Please reffer:

Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = HttpContext.Current.Server.MapPath("~/bin/plugins");

//Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = @"C:\inetpub\wwwroot\WebAPI\bin\plugins";
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(htmlFilePath, PDFFilePath,

//enable javascript
true,

//load timeout
100 * 100,

//page size
new SizeF(612, 792),

//page margins
new PdfMargins(0, 0));



string pdf_url_seperate_filename = getFilename(PDFFilePath);
Spire.Pdf.PdfDocument origDoc = new Spire.Pdf.PdfDocument();
origDoc.LoadFromFile(PDFFilePath);
Spire.Pdf.PdfDocument destDoc = new Spire.Pdf.PdfDocument();
foreach (Spire.Pdf.PdfPageBase page in origDoc.Pages)
{
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
Spire.Pdf.Graphics.PdfMargins margin = new Spire.Pdf.Graphics.PdfMargins();
margin.Top = unitCvtr.ConvertUnits(0f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(0f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
Spire.Pdf.PdfPageBase newPage = destDoc.Pages.Add(Spire.Pdf.PdfPageSize.Letter, margin);
newPage.Canvas.ScaleTransform(1.25f, 1.26f); /*735*/
newPage.Canvas.DrawTemplate(page.CreateTemplate(), new PointF(0, 0));
}
destDoc.SaveToFile(PDFFilePath, Spire.Pdf.FileFormat.PDF);
Last edited by ceipalAdmin on Thu May 02, 2019 10:17 am, edited 1 time in total.

ceipalAdmin
 
Posts: 37
Joined: Mon Apr 22, 2019 6:31 am

Tue Apr 23, 2019 2:38 am

Hello,

Thank you for contacting.
After testing your license. I was sure that it could work well. Please refer to the Web Demo which I provided for you via email. If there is any other question, welcome to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue May 07, 2019 11:39 am

Hai Spire Team I have quation about When converting Html to pdf if Original Pdf font change is possible is there

ceipalAdmin
 
Posts: 37
Joined: Mon Apr 22, 2019 6:31 am

Wed May 08, 2019 9:59 am

Hi,

Thanks for your inquiry.
Sorry that there is no good way to change the font family when converting HTML to PDF using the feature of Spire.PDF. However, the feature of our Spire.Doc could reach your goal. Please refer to the following sample code. Just feel free to write back if there is any question.
Code: Select all
            Document document = new Document();
            document.LoadFromFile("test.html", FileFormat.Html, XHTMLValidationType.None);
            foreach (Section section in document.Sections)
            {
                foreach (Paragraph paragraph in section.Paragraphs)
                {
                    foreach (DocumentObject docObject in paragraph.ChildObjects)
                    {
                        if (docObject.DocumentObjectType == DocumentObjectType.TextRange)
                        {
                            TextRange text = docObject as TextRange;
                            text.CharacterFormat.FontName = "Calibri";
                        }
                    }
                }
            }
            document.SaveToFile("HtmlFileToPDF.pdf", FileFormat.PDF);

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Fri May 10, 2019 12:15 pm

Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.Doc