@digicole/pdfmake-rtl 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +5 -181
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  **PDFMake RTL** is an enhanced version of PDFMake with **automatic RTL (Right-to-Left) language support** for Arabic, Persian (Farsi), Urdu, and other RTL scripts. No manual configuration needed - just write your content and the library automatically detects and handles RTL text!
7
7
 
8
+ All existing PDFMake code works unchanged, with automatic RTL support added!
9
+
8
10
  ## 🚀 Key Features
9
11
 
10
12
  - ✅ **Automatic RTL Detection** - No need to set `supportRTL` flags
@@ -27,6 +29,8 @@
27
29
  npm install @digicole/pdfmake-rtl
28
30
  ```
29
31
 
32
+
33
+
30
34
  ## 🎯 Quick Start NodeJs
31
35
 
32
36
  ```javascript
@@ -630,187 +634,7 @@ const advancedLongTableDoc = {
630
634
  };
631
635
  ```
632
636
 
633
- ## 🔄 Migration from PDFMake
634
-
635
- This is a **drop-in replacement** for PDFMake:
636
-
637
- ```javascript
638
- // Before
639
- const PdfPrinter = require('pdfmake');
640
-
641
- // After
642
- const PdfPrinter = require('@digicole/pdfmake-rtl');
643
- ```
644
-
645
- All existing PDFMake code works unchanged, with automatic RTL support added!
646
637
 
647
- ## 💻 Client-Side Usage
648
-
649
- ### Browser Integration
650
-
651
- Include the RTL-enabled PDFMake in your HTML:
652
-
653
- ```html
654
- <!DOCTYPE html>
655
- <html>
656
- <head>
657
- <title>PDFMake RTL Client Example</title>
658
- <script src="https://unpkg.com/@digicole/pdfmake-rtl/build/pdfmake.min.js"></script>
659
- <script src="https://unpkg.com/@digicole/pdfmake-rtl/build/vfs_fonts.js"></script>
660
- </head>
661
- <body>
662
- <script>
663
-
664
- pdfMake.vfs = vfs;
665
- pdfMake.fonts = {
666
-
667
- Nillima: {
668
- normal: 'Nillima.ttf',
669
- bold: 'Nillima.ttf',
670
- italics: 'Nillima.ttf',
671
- bolditalics: 'Nillima.ttf',
672
- },
673
- Roboto: {
674
- normal: 'Roboto-Regular.ttf',
675
- bold: 'Roboto-Medium.ttf',
676
- italics: 'Roboto-Italic.ttf',
677
- bolditalics: 'Roboto-MediumItalic.ttf',
678
- },
679
- };
680
- // Arabic/Persian/Urdu content with automatic RTL detection
681
- const docDefinition = {
682
- content: [
683
- // English text (auto-detected as LTR)
684
- { text: 'English Title', style: 'header' },
685
-
686
- // Arabic text (auto-detected as RTL)
687
- { text: 'العنوان العربي', style: 'header' },
688
-
689
- // Persian text (auto-detected as RTL)
690
- { text: 'عنوان فارسی', style: 'header' },
691
-
692
- // Urdu text (auto-detected as RTL)
693
- { text: 'اردو عنوان', style: 'header' },
694
-
695
- // Mixed content table (auto-detects direction per cell)
696
- {
697
- table: {
698
- widths: ['*', '*', '*'],
699
- body: [
700
- ['Name', 'الاسم', 'نام'], // Headers
701
- ['Ahmed', 'أحمد', 'احمد'], // Arabic/Persian names
702
- ['Fatima', 'فاطمة', 'فاطمہ'], // Mixed scripts
703
- ['Hassan', 'حسن', 'حسن'] // Common across languages
704
- ]
705
- }
706
- },
707
-
708
- // RTL list (bullets auto-positioned)
709
- {
710
- ul: [
711
- 'Arabic: العنصر الأول',
712
- 'Persian: مورد اول',
713
- 'Urdu: پہلا آئٹم',
714
- 'Mixed: Item واحد'
715
- ]
716
- }
717
- ],
718
-
719
- styles: {
720
- header: {
721
- fontSize: 18,
722
- bold: true,
723
- margin: [0, 0, 0, 10]
724
- }
725
- }
726
- };
727
-
728
- // Generate and download PDF
729
- function createPDF() {
730
- pdfMake.createPdf(docDefinition).download('rtl-document.pdf');
731
- }
732
-
733
- // Or open in new window
734
- function openPDF() {
735
- pdfMake.createPdf(docDefinition).open();
736
- }
737
- </script>
738
-
739
- <button onclick="createPDF()">Download RTL PDF</button>
740
- <button onclick="openPDF()">Open RTL PDF</button>
741
- </body>
742
- </html>
743
- ```
744
-
745
- ### Advanced Client-Side Features
746
-
747
- ```javascript
748
- // Custom font configuration for better RTL support
749
- pdfMake.fonts = {
750
- Roboto: {
751
- normal: 'https://fonts.googleapis.com/css2?family=Roboto',
752
- bold: 'https://fonts.googleapis.com/css2?family=Roboto:wght@700'
753
- },
754
- Amiri: {
755
- normal: 'https://fonts.googleapis.com/css2?family=Amiri',
756
- bold: 'https://fonts.googleapis.com/css2?family=Amiri:wght@700'
757
- },
758
- Vazir: { // Persian font
759
- normal: 'https://fonts.googleapis.com/css2?family=Vazir',
760
- bold: 'https://fonts.googleapis.com/css2?family=Vazir:wght@700'
761
- }
762
- };
763
-
764
- // RTL-aware document with automatic detection
765
- const advancedDoc = {
766
- content: [
767
- // Automatic language detection and appropriate styling
768
- {
769
- text: 'تقرير شهري - گزارش ماهانه - ماہانہ رپورٹ',
770
- style: 'title',
771
- // RTL auto-detected, right-aligned automatically
772
- },
773
-
774
- // Dynamic content with RTL detection
775
- {
776
- columns: [
777
- {
778
- width: '*',
779
- text: [
780
- 'Statistics:\n',
781
- 'المبيعات: ١٢٣٤\n', // Arabic
782
- 'فروش: ۱۲۳۴\n', // Persian
783
- 'فروخت: ۱۲۳۴' // Urdu
784
- ]
785
- },
786
- {
787
- width: '*',
788
- text: [
789
- 'Performance:\n',
790
- 'الأداء: ممتاز\n', // Arabic
791
- 'عملکرد: عالی\n', // Persian
792
- 'کارکردگی: بہترین' // Urdu
793
- ]
794
- }
795
- ]
796
- }
797
- ],
798
-
799
- styles: {
800
- title: {
801
- fontSize: 20,
802
- bold: true,
803
- margin: [0, 0, 0, 20]
804
- // alignment automatically set based on content direction
805
- }
806
- },
807
-
808
- defaultStyle: {
809
- // RTL languages get Amiri/Vazir, LTR gets Roboto automatically
810
- font: 'Roboto'
811
- }
812
- };
813
- ```
814
638
 
815
639
  ### React/Vue Integration
816
640
 
@@ -904,7 +728,7 @@ yarn run build
904
728
  MIT
905
729
 
906
730
  ## Authors pdfmake-rtl
907
- *[@aysnet1](httpss://github.com/aysnet1)
731
+ * [@aysnet1](httpss://github.com/aysnet1)
908
732
 
909
733
  ## Authors pdfmake
910
734
  * [@bpampuch](https://github.com/bpampuch) (founder)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digicole/pdfmake-rtl",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Enhanced PDFMake with automatic RTL (Arabic/Persian/Urdu) support - Complete standalone package",
5
5
  "main": "index.js",
6
6
  "browser": "build/pdfmake.js",