[ 
https://issues.apache.org/jira/browse/PDFBOX-3550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15638969#comment-15638969
 ] 

Omid Pourhadi commented on PDFBOX-3550:
---------------------------------------

Hi,

this is a simple iText example which works smoothly and correctly and it is 
using nothing but AWT and Java without any external libraries AFAIK, I'm not a 
font expert but I'm wondering how come this works.

 {code:java}
        try
        {
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream("/home/omidp/temp/out.pdf"));
            document.open();
            //
            MultiColumnText mct = new MultiColumnText();
            mct.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
            mct.setColumnsRightToLeft(true);
            BaseFont bf = 
BaseFont.createFont("/home/omidp/sts_workspace/htmltopdf/src/main/resources/BYekan.ttf",
 BaseFont.IDENTITY_H, true);
            Font font = new Font(bf, 12);
            Paragraph p = new Paragraph("سلام", font);
            mct.addRegularColumns(document.left(), document.right(), 10f, 3);
            mct.addElement(p);
            //
            document.add(mct);
            document.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
{code}

PS : it is based on iText 2.1.7 (one of the oldest version)

> OpenType Shaping
> ----------------
>
>                 Key: PDFBOX-3550
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3550
>             Project: PDFBox
>          Issue Type: New Feature
>          Components: FontBox, PDModel
>         Environment: All
>            Reporter: Omid Pourhadi
>              Labels: unicode
>         Attachments: BYekan.ttf
>
>
> the problem is, in some languages letters need to be joined together for 
> example, consider this word 
> {color:red}
> سلام 
> {color}
> but after creating a pdf it contorts to 
> {color:red}
> س‌ل‌ام
> {color}
> with extra semi-spaces. I think this is a bug in pdfbox and definetly is not 
> related to font.
> {code:title=SampleCode.java|borderStyle=solid}
> public class SampleCode
> {
>     public static void main(String[] args) throws IOException
>     {
>         
>         PDDocument document = new PDDocument();
>       //this font perfectly works in iText and JasperReport with the same text
>         PDFont titleFont = PDType0Font.load(document, 
> SampleCode.class.getResourceAsStream("/BYekan.ttf"));
>         PDPage page = new PDPage(PDRectangle.A4);
>         document.addPage(page);
>         PDPageContentStream contentStream = new PDPageContentStream(document, 
> page);
>         contentStream.beginText();
>         contentStream.setFont(titleFont, 12);
>         contentStream.newLineAtOffset(0, 100);
>         contentStream.showText("سلام");
>         contentStream.endText();
>         contentStream.close();
>         
>       
>         document.save(new File("/home/omidp/temp/htmltopdf/output.pdf"));
>         document.close();
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to