Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Sep 16, 2021 11:58 am

Hi,
I'm creating a PowerPoint table row by row and inserting text but having trouble laying out shapes in the right positions. The row heights and OffsetY positions are incorrect when adding text in non-standard fonts. It appears as if the row heights are calculated using standard fonts like 'Calibri', but if text is inserted into a table cell in a different font, say, Century, the row height and OffsetY positions don't reflect the fact that the text now wraps across more rows.

An example is attached - the first slide uses Calibri font and the green triangles are aligned with the table rows. The second slide uses Century font and the green triangles (which are positioned using OffsetY) are in the wrong place.

Is there any way in which I can get the row heights to reflect the font being used?
Thanks,
John

John.Hunt
 
Posts: 3
Joined: Tue Sep 14, 2021 2:59 pm

Fri Sep 17, 2021 12:38 pm

Hello,

Thanks for your inquiry.
I used the following code to get the row height and offsetY, indeed found that there was no difference between different fonts. I will post this issue to our Dev team for further investigation, if there is any news, I will inform you. Sorry for the inconvenience caused.
Code: Select all
double heih = table[0, 0].Height;
double y1 = table[0, 0].OffsetY;

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Sep 20, 2021 12:40 pm

Hi Annika,

Many thanks for the reply and for taking the trouble to look at this. In case it's helpful, here is sample code and a template that demonstrates the issue. I've attached both an empty template and the template after population by the code below. The triangle is misplaced in the example using Century font, but if the font is changed to 'Calibri' the triangle is correctly aligned to the top of the next row.

Dim projectTable As Spire.Presentation.ITable = ppt.Slides(0).Shapes(0)

Dim dummytext As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam dapibus sem eget ante auctor rutrum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas volutpat justo et justo tristique hendrerit. Donec in magna ut turpis vehicula feugiat. Aliquam luctus lorem purus, ut volutpat felis malesuada dictum. Donec id ante urna. Vivamus id ligula eros. Donec vel ex malesuada, aliquam enim in, posuere massa. In hac habitasse platea dictumst. Vivamus et elementum mi. Praesent luctus eros consequat magna suscipit, et accumsan dui sagittis. Fusce pellentesque magna nulla, vel congue sem varius non. Vivamus justo sapien, rutrum aliquam feugiat eget, mattis in est. Suspendisse congue facilisis purus vitae fringilla. Curabitur dignissim libero a elementum tristique. Nam facilisis, justo et ullamcorper ornare, risus nulla pulvinar enim, ac tristique nisl lectus eget erat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nulla venenatis enim in fringilla interdum. Vivamus malesuada quis dolor quis pulvinar. Proin tempus vel risus eu sollicitudin. Nam augue lorem, tincidunt sit amet metus a, pretium euismod nisi."

projectTable(1, 1).TextFrame.TextRange.Text = dummytext
projectTable(1, 1).TextFrame.TextRange.LatinFont = New TextFont("Century")

Dim RAGTriangle = ppt.Slides(0).Shapes.AppendShape(ShapeType.RightTriangle, New RectangleF(projectTable.Frame.Left + projectTable(0, 2).OffsetX, projectTable.Frame.Top + projectTable(0, 2).OffsetY, 24, 24))
RAGTriangle.Rotation = 90

John.Hunt
 
Posts: 3
Joined: Tue Sep 14, 2021 2:59 pm

Tue Sep 21, 2021 7:36 am

Hello,

Thanks for your detailed information.
I tested your case with our latest Spire.Presentation (Spire.Presentation Pack Hotfix Version:6.9.2), but didn't find the position of triangle was incorrect. Here I uploaded my outputs for your reference. If you were not using the latest version, please first give it a try. If the issue still happens after trying, please provide your testing environment, such as OS info (E.g. Windows7, 64bit), Region setting (E.g. China, Chinese) as well as your app type (E.g. Console app, Net Framework 4.7.2) for further information. Looking forward to your reply.

Best Regards,
Nina
E-iceblue support team
User avatar

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

Thu Sep 23, 2021 10:48 am

Thank you, it's very helpful to see your outputs and learn that this works correctly in your environment. I've tried on a second system and it's working there for me as well, so this does look like a problem with a specific environment. I suspect the issue is that the font isn't correctly installed on the production webserver. Please consider this resolved and thank you for your assistance.

[Edit in case anyone else is struggling with this - solved by embedding the font in the Powerpoint template]

John.Hunt
 
Posts: 3
Joined: Tue Sep 14, 2021 2:59 pm

Fri Sep 24, 2021 7:36 am

Hello,

Glad to hear that your issue has been resolved and thanks for sharing your solution.
If you have other question, please feel free to write back.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation

cron