Skip to content

New Version https://github.com/life888888/asciidocfx-pdf-fop-cjk-patch , AsciidocFX 1.7.6+, Please Use https://github.com/life888888/asciidoctor-pdf-cjk-ext#asciidocfx , Can make AsciidocFX export PDF to display Chinese, Japanese, Korean characters normally and Bold Italic Italic Bold Italic Bold Italic Patch setting automation command.

License

Notifications You must be signed in to change notification settings

life888888/asciidocfx-pdf-cjk-patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asciidocfx-pdf-cjk-patch

Display of Chinese, Japanese, and Korean characters in AsciidocFX exported PDF and automatic setting of Bold Italic Italic Bold Bold Italic. Asciidoc FX PDF CJK Patch is to set the font and style settings of CJK (Chinese, Japanese, Korean) that display as # when CJK text cannot be displayed when Asciidoc FX produces PDF. To avoid the common problem of AsciidocFX outputting PDF, Chinese characters are not displayed normally. After executing this Asciidoc FX PDF CJK Patch, AsciidocFX should be able to generate PDFs with Chinese characters normally.

Before modification - Chinese cannot be displayed normally, # appears

BeforePatch

After modification - Chinese can be displayed normally, bold, italic, and italic bold are all available

AfterPatch

If you use AsciidocFX 1.7.6+ and want to use ASCIIDOCTOR instead to generate PDF, you can refer to https://github.com/life888888/asciidoctor-pdf-cjk-ext#asciidocfx

The following is translated from Chinese to English using Google Translate.

1. Features

  • Automatically download fonts

  • Automatic settings font and style settings

  • supports italics

  • support italic bold

2. How to install PDF CJK Patch

Please go to Release to download

  • asciidocfx-pdf-cjk-patch-all.zip (TW , CN , JP , KR all in one)

Important
Important
  • This Asciidoc FX PDF CJK Patch currently only works automatically on Linux

    • If you are a Windows or MacOS user, please refer to ManualSetting.adoc[Manual Setting and Execution].

  • This Asciidoc FX PDF CJK Patch is currently only tested for Asciidoc FX 1.7.4/1.6.0!

    • Not guaranteed to automatically apply to other versions of Asciidoc FX.

    • But you can manually modify the settings. Please refer to ManualSetting.adoc [manual setting execution].

2.1. Install and execute

After unpacking asciidocfx-pdf-cjk-patch-all.zip , copy the src directory contents to your AsciidocFX directory.

The directory structure is as follows: Please make sure the location is correct

The copied directory structure
AsciidocFX
|-- AsciidocFX
|-- AsciidocFX.vmoptions
|-- pdf-cjk-patch-TW.sh <- Add
|-- pdf-cjk-patch-CN.sh <- Add
|-- pdf-cjk-patch-JP.sh <- Add
|-- pdf-cjk-patch-KR.sh <- Add
`-- pdf-cjk-patch (Directory) <- Add

Please choose one of the following according to your needs:

Please replace /yourPath/AscidocFX with the actual installation path of your AsciidocFX

To set the font and style of Traditional Chinese, please execute the following commands
cd /yourPath/AsciidocFX
./pdf-cjk-patch-TW.sh
To set the Simplified Chinese font and style, please execute the following commands
cd /yourPath/AsciidocFX
./pdf-cjk-patch-CN.sh
To set the Japanese font and style, please execute the following commands
cd /yourPath/AsciidocFX
./pdf-cjk-patch-JP.sh
To set the Korean font and style, please execute the following commands
cd /yourPath/AsciidocFX
./pdf-cjk-patch-KR.sh

2.2. Results after execution

The copied directory structure
AsciidocFX
|-- conf
    |-- docbook-config
    │   |-- fo-pdf.xsl (modified)
    │   |-- fo-pdf.xsl.org (Copy backup original file:  fo-pdf.xsl )
    │   |-- fop.xconf.xml (modified)
    │   `-- fop.xconf.xml.org (Copy backup original file: fop.xconf.xml)
    `-- fonts
        `-- KaiGenGothic (create)
            |-- KaiGenGothicXX-Bold-Italic.ttf (Download)
            |-- KaiGenGothicXX-Bold-Italic.xml (Copy)
            |-- KaiGenGothicXX-Bold.ttf (Download)
            |-- KaiGenGothicXX-Bold.xml (Copy)
            |-- KaiGenGothicXX-Regular-Italic.ttf (Download)
            |-- KaiGenGothicXX-Regular-Italic.xml (Copy)
            |-- KaiGenGothicXX-Regular.ttf (Download)
            `-- KaiGenGothicXX-Regular.xml (Copy)

Where XX should be your own language such as TW , CN , JP , KR

Warning
WARNING

The modification is completed, in order to avoid some problems, please delete the AsciidocFX setting directory in your home directory first.

  • .AsciidocFX-1.7.4

  • .com.kodedu.boot.AppStarter

3. how to test

The project provides some files for testing. After you complete the settings, you can test it immediately.

Execute AsciidocFX. Open the AsciidocFX/pdf-cjk-patch/testdoc directory:

Select the corresponding test file:

  • PDF-CJK-TEST_TW.adoc - Used to test Traditional Chinese

  • PDF-CJK-TEST_CN.adoc - Used to test Simplified Chinese

  • PDF-CJK-TEST_JP.adoc - Used to test Japanese (this is produced by Google Translate)

  • PDF-CJK-TEST_KR.adoc - No, because I didn’t do it.

If the setting is successful, your PDF will see Chinese(or your language), and there are bold, italic, italic bold Chinese.

3.1. PDF check items

Checked list
  • ❏ Whether all Chineseor your language fonts are displayed.

  • ❏ Whether the general font is displayed normally?

  • ❏ Whether the bold font is displayed normally?

  • ❏ Whether italic fonts are displayed normally?

  • ❏ Is italic bold font displayed normally?

  • ❏ Whether the second-level title, the third-level title, and the fourth-level title are officially displayed?

  • ❏ Open the PDF, click Properties, check the font, and see if the embedded font name corresponds to the CJK font you set. ( KaiGenGothicXX , KaiGenGothicXX-Bold , KaiGenGothicXX-BoldItalic , KaiGenGothicXX-Italic )

PDF →Properties→Fonts

pdf fonts

4. Restore original file

AsciidocFX/conf/docbook-config has backups of original configuration files ( fo-pdf.xsl.org and fop.xconf.xml.org)

  • Please overwrite fo-pdf.xsl with fo-pdf.xsl.org

  • Please overwrite fop.xconf.xml with fop.xconf.xml.org

Warning
WARNING

After the modification is completed, in order to avoid some problems, please delete the AsciidocFX setting directory in your home directory first.

  • .AsciidocFX-1.7.4

  • .com.kodedu.boot.AppStarter

5. Used Technologies

AsciidocFX - PDF CJK Patch using Linux shell script

Related Linux programs:

  • wget

  • md5sum

  • patch

Fonts:

6. Known Issues

None

7. Changelog

None

8. Q & A

Q: If not Asciidoc FX 1.7.4 will it also work?

  • I have only tested .sh automation on Asciidoc FX 1.7.4 / 1.6.0

  • Other versions may also be able to apply .sh automation

    • Depends on whether the content of fop.xconf.xml and fo-pdf.xsl in AscidocFX/conf/docbook-config/ is consistent with the content of 1.7.4.

  • If other versions can’t automate apply, but you can still manually modify the settings file.

Q: Why use this KaiGen Gothic font?

  • Since Asciidoctor PDF - CJK also uses , there should be no licensing issues.

  • In addition, it is currently Open Source that provides italic, italic bold CJK fonts.

Q: Can I use another font?

  • Other ttf and ttc fonts can be used, but are not provided in this project.

  • However, if there is no italic, the corresponding font of italic bold will cause the text that should be displayed in italic and italic bold when generating PDF, and will be displayed in the normal style.

Q: Starting from AsciidocFX 1.7.6, with this modification, the output of Chinese PDF fails again?

Because starting from AsciidocFX 1.7.6, its default pdf output is set using the asciidoctor-pdf module.

So we have to manually modulate the settings to use the fop module settings for the original old version.

If you want to continue using FOP to generate PDF.

AsciidocFX 1.7.6, its default pdf output is asciidoctor-pdf

PDFSetting 001

① Please click on the right tab Settings

② Then click on the upper tab PDF Settings

③ Click the drop-down menu in PDF Converter or PDF Engine

Drop-down menu, click on the FOP option

Drop-down menu, click on the FOP option

PDFSetting 002

Click Done and click Save. Then click Load.

Click Done and click Save. Then click Load.

PDFSetting 003

9. FAQ

On AsciidocFX, the problem that Chinese characters in PDF cannot be displayed:

  • Chinese characters cannot be displayed and become #.

The easiest setting is to add fonts.

AsciidocFX/conf/docbook-config/fop-config.xml

            <fonts>
                <directory>C:\Windows\Fonts</directory>
                <auto-detect/>
            </fonts>

You may find that AsciidocFX may be able to produce PDFs containing Chinese characters.

But the next problem occurs:

  • It still cannot be displayed properly when encountering a third-level title or setting text with italics

The third-level title cannot display Chinese normally and the italic font setting text cannot display Chinese normally. It is the same problem.

AsciidocFX can’t get the corresponding italic font. Therefore, the parts that need to use italics (such as third-level headings) will not be able to display Chinese properly.

Because general Chinese fonts do not have italic or bold italic fonts,

So to solve this problem:

  • Method 1: Install Chinese fonts, including four styles of fonts (normal, bold, italic, bold italic)

  • Method 2: Modify the settings of AsciidocFX/conf/docbook-config/fop.xconf.xml of AsciidocFX

    • deceive the system, tell the system

      • Italic also uses normal style fonts

      • Bold italic also uses bold font

Method 2 Advantages: Chinese can be displayed normally. Disadvantage: Italics will only be displayed in normal style, bold italics will only be displayed in bold.

If your file has a special definition for italics, after converting it to PDF through method 2, there will be no italics.

10. Support

Support AsciidocFX - PDF CJK Patch with pull requests or open an issue for bug & feature requests.

About

New Version https://github.com/life888888/asciidocfx-pdf-fop-cjk-patch , AsciidocFX 1.7.6+, Please Use https://github.com/life888888/asciidoctor-pdf-cjk-ext#asciidocfx , Can make AsciidocFX export PDF to display Chinese, Japanese, Korean characters normally and Bold Italic Italic Bold Italic Bold Italic Patch setting automation command.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages