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.

Wed Sep 06, 2017 8:56 pm

Hi,
I am working on generating PDF file using Spire.PDF. I need to change the font size of the PDF doc to make it smaller. How do I do it?

Thanks,
Lucy

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Thu Sep 07, 2017 5:56 am

Hello Lucy,

Thanks for your inquiry.
Our Spire.Pdf does support the feature of changing font, but somehow the invalid setting of font size happens to be a bug at present. I have logged it in our bug tracking system, 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

Thu Sep 07, 2017 2:57 pm

Hi Jane,
The issue I am having now is how to fit the html contents into a PDF page. Please refer to attached screenshot. You can see the first header columns are cut off(they are 2 more columns missing) because of the page size. This is our code snippet:

_msPDF = new MemoryStream();
_doc = new PdfDocument();
_doc.UseHighQualityImage = true;

var htmlLayoutFormat = new PdfHtmlLayoutFormat();
htmlLayoutFormat.IsWaiting = false;
htmlLayoutFormat.Layout = PdfLayoutType.Paginate;


var setting = new PdfPageSettings();
setting.Size = PdfPageSize.Letter;
setting.Orientation = PdfPageOrientation.Portrait;
setting.Margins.All = 0;
setting.Height = 732;
setting.Width = 502;

........................
Thread thread = new Thread(() =>
{
_doc.LoadFromHTML(_htmlContent, true, setting, htmlLayoutFormat);
});

I also tried to change from setting.Orientation = PdfPageOrientation.Portrait;
to setting.Orientation = PdfPageOrientation.Landscape;
That doesn't help either.
How to work around that?

Thanks,
Lucy

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Fri Sep 08, 2017 2:38 am

Hi Lucy,

Thanks for your details.
If you use the "LoadFromHTML" method, you need to make sure the page size you set can hold all the content of the html.
Anyway, here's another method you could try.
https://www.e-iceblue.com/Tutorials/Spi ... lugin.html
If therer's still any issue, please write bcak and share your sample html string.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Fri Sep 08, 2017 4:22 pm

Hi Jane,
I am trying to use the code in your example. I downloaded Plugins-x64.zip and put to a folder accordingly(please see screenshot):
And when I run the application, it gives me the error: The convention provider can not be found(please see screenshot).
Do you know if I put the plugins at the right location?

Thanks,
Lucy

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Mon Sep 11, 2017 7:00 am

Hi Lucy,

Thanks for your response.
According to the screeshoot, you have put the plugin folder at the wrong location. Please put it under the same folder of Spire.Pdf.dll, together with the executable file, the path is always the bin folder uder the debug or the release like below.
1.png

If you do not put the plugin at the right place, you can also use the code below to specify the plugin path.
Code: Select all
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.PluginPath = @"F:\vs\SpirePdfDemo\WindowsFormsApplication1\bin\Debug\plugins"

If there's still any issue, welcome to write back.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Mon Sep 11, 2017 2:03 pm

I tried both of the suggestions, none of them is working. I still get the same error message:

lsong
 
Posts: 36
Joined: Wed Feb 01, 2017 4:13 pm

Tue Sep 12, 2017 6:39 am

Hi Lucy,

Thanks for your response.
Since the iis express invokes the 32 bit version by default in visual studio, if you use the plugin of 64 bit, you need to invoke the iis express for 64 bite manually, and is a little unconvenient because this can only be managed in the registry. To figure the issue out, we recommend you using the Plugins-x32, which also works well for the 64 bit system.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Sat Sep 30, 2017 3:59 am

Hello Lucy,

Now the feature of changing the font size of the whole docuemnt is availabe and the hotfix Spire.Office(2.16.18) is published, you could download it from the following link.
https://www.e-iceblue.com/Download/down ... t-now.html
Below is the code for your reference.
Code: Select all
 PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(@"ReplaceText.pdf");
            PdfUsedFont[] fonts = pdf.UsedFonts;
            foreach (PdfUsedFont font in fonts)
            {
               //change the font size
                PdfTrueTypeFont trueTypeFont =
new PdfTrueTypeFont(new System.Drawing.Font(font.Name, 5f), true);
                font.Replace(trueTypeFont);
            }
            pdf.SaveToFile("11545.pdf");


Sincerely,
Jane
E-iceblue support team
User avatar

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

Wed Nov 27, 2019 12:38 pm

Hi,

I am using "Spire.PDF.HtmlConverter.Qt" plugin along with free license of Spire.Pdf for now.

The program shows the exception as: The font being replaced is not a standard font of Type 1 font or a non-embeded TrueType font

Any resolution to replace the font as in the above example avoiding this issue?

nsivasamy
 
Posts: 5
Joined: Mon Jul 15, 2019 4:26 pm

Thu Nov 28, 2019 8:38 am

Hi,

Thanks for your inquiry.
To help us investigate your issue accurately, could you please offer us the following information?
1. Your input Files.
2. The complete code you were using which could reproduce your issue directly.
3. The OS and Region information, e.g. Win7 64bit, China/Chinese.

You could upload them here or send us(support@e-iceblue.com) via email.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Dec 24, 2019 8:08 am

If your team solve the font size problem related to html to pdf using plugins pleace let us know because I have same issue ..

ashansara95
 
Posts: 1
Joined: Fri Nov 08, 2019 5:27 am

Tue Dec 24, 2019 9:22 am

Hi,

Thanks for your inquiry.
Do you mean the font size changed when you converted your Html file to Pdf file? If so, to help us investigate your issue accurately, please offer us the following information.
1. Your input file.
2. The complete code you were using.
3. Your result file.
4. The OS and Region information, e.g. Win7 64bit, China/Chinese.

You could upload them here or send us(support@e-iceblue.com) via email.

If I misunderstand, please offer us the detail information.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.PDF