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 Aug 19, 2020 7:20 am

hi.
i need to use persian or arabic language for write text in pdf file with spire.pdf for java?
how use right to left text direction in spire.pdf for java?

my code
Code: Select all
package javaapplication8;
import com.spire.pdf.*;
import com.spire.pdf.graphics.PdfCanvas;
import com.spire.pdf.graphics.PdfRGBColor;
import com.spire.pdf.graphics.PdfSolidBrush;
import com.spire.pdf.graphics.PdfStringFormat;
import com.spire.pdf.graphics.PdfTextWidget;
import com.spire.pdf.graphics.PdfTrueTypeFont;
import java.awt.Color;
import java.awt.Font;
import java.time.format.TextStyle;
import static javafx.scene.text.Font.font;
public class JavaApplication8 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
               PdfDocument pd = new PdfDocument();
       
        PdfPageBase p = pd.getPages().add();
       
        PdfTrueTypeFont f = new PdfTrueTypeFont(new Font("Times New Roman",Font.LAYOUT_RIGHT_TO_LEFT,14));
        PdfSolidBrush b = new PdfSolidBrush(new PdfRGBColor(Color.ORANGE));
        String t = "سلام";
        //PdfTextWidget w = new PdfTextWidget(t,f,b);
        //w.draw(p,50,30);
        PdfStringFormat d = new PdfStringFormat();
        d.setRightToLeft(true);
        p.getCanvas().drawString(t, f, b, 0, 30,d);
       
        pd.saveToFile("2.pdf");
    }
   
}



result in attachment

my word in arabic "سلام" but word in result "س ل ا م"

mjabbari
 
Posts: 3
Joined: Sat Apr 21, 2018 3:54 pm

Wed Aug 19, 2020 9:48 am

Hello,

Thanks for your post.
When drawing your text string, comparing directly adding it by Adobe, I did notice that the font glyph is inconsistent. I have logged this issue into our bug tracking system with the ticket SPIREPDF-3516 for further investigations and fixing. Once there is any update, I will let you know asap. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Wed Aug 19, 2020 4:21 pm

Thank you. I need your help to solve this problem.
I am using 64 bit version of Windows 10.
I am also using spire.pdf version 3.8.2.
If possible, send me a suitable font for Arabic typing.

mjabbari
 
Posts: 3
Joined: Sat Apr 21, 2018 3:54 pm

Thu Aug 20, 2020 2:30 am

Hello,

Thanks for your feedback.
Our Dev team is investigating this issue now. Once there is any update, I will let you know immediately. Thanks for your patience.

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Return to Spire.PDF