Skip to content

Japanese font error #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ThantsinKS opened this issue Apr 8, 2025 · 0 comments
Open

Japanese font error #351

ThantsinKS opened this issue Apr 8, 2025 · 0 comments

Comments

@ThantsinKS
Copy link

ThantsinKS commented Apr 8, 2025

Describe the bug
japanese font error i am using sail

To Reproduce
public function generatePdf($jasperFile, $outputName = null)
{

    if (!file_exists($jasperFile)) {
        Log::error("Jasper file not found: $jasperFile");
        return [
            'success' => false,
            'message' => 'Jasper file not found'
        ];
    }
    if (!$outputName) {
        $outputName = pathinfo($jasperFile, PATHINFO_FILENAME);
    }

    $outputDir = storage_path('app/reports/output/JPN');
    if (!is_dir($outputDir)) {
        mkdir($outputDir, 0755, true);
    }

    $output = $outputDir . '/' . $outputName;

    $options = [
        'format' => ['pdf'],
        'locale' => 'en',
        'params' => [
            'HEADER_USER_ID' => 25
        ],
        'locale' => 'ja_JP',
    ];

    // putenv('CLASSPATH=' . '/var/www/html/docker/sail_8.4/fonts/NotoSansJP-Regular.jar');

    try {
        $jasper = new PHPJasper;
        $result = $jasper->process(
            $jasperFile,
            $output,
            $options,
        )->execute();

        Log::info("Jasper processing completed successfully.");

        Log::info("Jasper processing output: " . ($result ?? 'No output'));

        $pdfFile = $output . '.pdf';

        if (file_exists($pdfFile)) {
            return [
                'success' => true,
                'message' => 'PDF generated successfully',
                'file_path' => $pdfFile
            ];
        } else {
            Log::error("PDF generation completed but file not found: $pdfFile");
            return [
                'success' => false,
                'message' => 'PDF generation completed but file not found'
            ];
        }
    } catch (Exception $e) {
        Log::error("Error generating PDF: " . $e->getMessage());
        return [
            'success' => false,
            'message' => 'Error generating PDF: ' . $e->getMessage()
        ];
    }
}

Screenshots

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant