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 Dec 23, 2020 1:50 pm

Hi

I am evaluating spire.pdf, we are having issue exporting pdf to images, here is my code

PdfDocument pdf = new PdfDocument();

PdfPageBase page = pdf.Pages.Add(PdfPageSize.A1, new PdfMargins(0));

//PdfTrueTypeFont font = new PdfTrueTypeFont("Arial Unicode MS", 11f);
PdfCjkStandardFont font1 = new PdfCjkStandardFont(PdfCjkFontFamily.MonotypeSungLight, 11f);
page.Canvas.DrawString(teststring, font1, PdfBrushes.Red, 50, 50);
page.Canvas.DrawString("中國", font1, PdfBrushes.Red, 50, 70);
//pdf.SaveToFile(@"c:\temp\result.pdf");

using var stream = pdf.SaveAsImage(0);
Image image = null;

image = Image.FromStream(stream);
image.Save(@"C:\temp\sign.bmp");
image.Save(@"C:\temp\best.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
// System.Diagnostics.Process.Start("result.pdf");

Both bmp and jpeg are not save correctly, please see the attachment

Second Question:
Is there anyway to do auto height, i don't know the exact height, can it base on how much height the string takes?

schang123
 
Posts: 2
Joined: Wed Dec 23, 2020 1:39 pm

Thu Dec 24, 2020 4:09 am

Hello,

Thanks for your inquiry!

For the first question: I have tested PdfCjkStandardFont font1 = new PdfCjkStandardFont(PdfCjkFontFamily.MonotypeSungLight, 11f); using Spire.PDF for .NET Standard dll. It did exist the issue of Chinese (Traditional) character drawing failure and I have logged it in our issue tracking system with the ticket SPIREPDF-3923 for further investigation.

We will let you know if there is any update. Sorry for the inconvenience caused. As a temporary method, please use PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 11f), true); to draw the text.

For the second question: Do you want to adjust the Y-coordinate of the second line of text based on the height of the first line of text, right? If so, please refer to the following code.
Code: Select all
            PdfDocument pdf = new PdfDocument();

            PdfPageBase page = pdf.Pages.Add(PdfPageSize.A1, new PdfMargins(0));

            PdfTrueTypeFont font = new PdfTrueTypeFont("Arial Unicode MS", 11f, PdfFontStyle.Regular, true, false);
            String text1 = "1 of 123456";
            page.Canvas.DrawString(text1, font, PdfBrushes.Red, 50, 50);

            PdfStringFormat format = new PdfStringFormat();
            //get size of text1
            SizeF size = font.MeasureString(text1, format);
            float Y = size.Height + 50;

            page.Canvas.DrawString("中國", font, PdfBrushes.Red, 50, Y);


If the code doesn’t meet your needs, please provide us with your input file and the excepted result for further investigation. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Mar 19, 2021 10:02 am

Hello,

Thanks for your patience.

Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:7.3.3 which fixes the issue of the SPIREPDF-3923.

Please download the fix version from the following links to test.

Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/7.3.3

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Mar 29, 2021 3:02 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF