Skip to content
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

Converting pdf to img file name containing Chinese failed #1035

Closed
While4 opened this issue Apr 5, 2024 · 2 comments
Closed

Converting pdf to img file name containing Chinese failed #1035

While4 opened this issue Apr 5, 2024 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@While4
Copy link

While4 commented Apr 5, 2024

image image

Hi Stirling-PDF Team,
When I use the pdf to img function, if the name of the pdf file I upload contains Chinese, at this time, I will get a file named "download" instead of the "download.zip" file, although I can manually add ".zip" to make it work.

@While4 While4 changed the title The file name does not support Chinese characters Converting pdf to img file name containing Chinese failed Apr 5, 2024
@xiaoxuesheng1006
Copy link

xiaoxuesheng1006 commented Apr 8, 2024

Use URLEncoder to solve errors caused by non-ASCII characters. You need to add file name modifications to the last else branch in the interface /pdf/img. The specific code is as follows

` // support Chinese file names

        String encodedFilename =
                URLEncoder.encode(filename, StandardCharsets.UTF_8.toString())
                        .replaceAll("\\+", "%20");

        // return the Resource in the response

        return ResponseEntity.ok()
                .header(
                        HttpHeaders.CONTENT_DISPOSITION,
                        "attachment; filename=" + encodedFilename + "_convertedToImages.zip")
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .contentLength(resource.contentLength())
                .body(resource);`

@While4
Copy link
Author

While4 commented Apr 8, 2024

It does work, thank you

@sbplat sbplat added bug Something isn't working enhancement New feature or request labels Apr 8, 2024
Frooodle added a commit that referenced this issue Apr 28, 2024
Frooodle added a commit that referenced this issue Apr 28, 2024
* fix for #1035

* Update ConvertImgPDFController.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants