filippotoso / pdf-watermarker

Simple PDF Watermarker with Laravel support
Other
6 stars 7 forks source link

Arabic world not show properly. #8

Open NALAWALAMURTUZA opened 3 months ago

NALAWALAMURTUZA commented 3 months ago

Arabic text "نسخة للاطلاع".

Problem

It shows left to right instead of right to left.

Code

 public function document_watermark_without_purchase(String $path, String $fileName)
    {
        try {
            $pdf = new Pdf($path);
            $font = storage_path('app/Cairo-Regular.ttf');
            $watermark = new TextWatermark('نسخة للاطلاع', $font, 84, 40, '#660000');
            $watermarker = new PDFWatermarker($pdf, $watermark);
            $position = new Position(Position::TOP_CENTER, 0, 64);
            $watermarker->setPosition($position);
            $watermarker->setAsBackground();
              //$watermarker->setAsOverlay();
            return $watermarker->stream($fileName);
        } catch (\Throwable $th) {
            Log::error($th);
            return response()->file($path);
        }
    }

Output

Screenshot (227)

@filippotoso please help me for this issue. and thanks in advance.

filippotoso commented 1 month ago

Hi, i'm sorry but I don't have experience with RTL scripts. Can you provide an example of the current and the expected outputs?