We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Words rendering some text is render to shape

I'm using Document.renderToScale, find some text is rendering to a shape(or GlyphVector?), and others is right
what happened?
how can I fixed it?

Hi there,

Thanks for your inquiry. Could you please attach your input Word document along with problematic image here for testing? I will investigate the issue on my side and provide you more information.

I test with the attachement web.doc

and when I test with test.doc


debug this code:
int count = text.length();
float[] xs = new float[count], ys = new float[count];
Font fnt = this.getFont();
FontRenderContext frc = this.getFontRenderContext();
TextLayout layout = new TextLayout(text, fnt, frc);
Arrays.fill(ys, layout.getAscent() * scale);
for (int i = 0; i < layout.getCharacterCount(); i++) {
float[] ci = layout.getCaretInfo(TextHitInfo.leading(i));
xs[i] = ci[0] * scale;
}

when step in layout.getCaretInfo(TextHitInfo.leading(i))
the eclipse debugger suspended at
zzSQ.zzZ(zzZU, Graphics2D) line: 113
and has nothing result

Hi there,

Thanks for sharing the detail. Unfortunately, from the shared detail the problem which you are facing is not clear. It would be great if you please share some more detail about your query along with runnable simple Java application to reproduce this issue at our end.

I write a custom Graphics2D like itext’s PdfGraphics2D


public void drawGlyphVector(GlyphVector g, float x, float y) {
this.fill(g.getOutline(x, y));
}

and

public void drawString(String text, float x, float y) {
System.out.println(text);
}

then
Document doc = new Document(“D:/test.doc”);
for (int i = 0; i < doc.getPageCount(); i++) {
PageInfo info = doc.getPageInfo(i);
double w = PageUnit.point2mill(info.getWidthInPoints());
double h = PageUnit.point2mill(info.getHeightInPoints());

Page page = myDoc.newPage();
page.setSize((float) w, (float) h);
Graphics2D g2d = page.canvas();
doc.renderToScale(i, g2d, 0, 0, scale);
g2d.dispose();
}

I found some word’s text render is call drawGlyphVector
but I want all of those call drawString

Hi there,

Thanks for your feedback. It seems that you are using Aspose.Words and Aspose.Pdf. It would be great if you please share some more detail about your query along with following detail.


  • Please share the issue which you are facing while using Aspose APIs
  • Please share a runnable simple Java application that demonstrates the code you used to generate
    your output.
  • Please share what exact you want to achieve using Aspose APIs

As soon as you get these pieces of information to
us we’ll start our investigation into your issue.