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

Help wanted: How to attach file with unicode name #513

Closed
RangerMak opened this issue Apr 13, 2021 · 2 comments · Fixed by #542
Closed

Help wanted: How to attach file with unicode name #513

RangerMak opened this issue Apr 13, 2021 · 2 comments · Fixed by #542
Milestone

Comments

@RangerMak
Copy link

I'm trying to attach file using writer.addFileAttachment().
Name of file contains cyrillic symbols which not shown in resulted PDF.

How to attach file with unicode name?

@RangerMak
Copy link
Author

Solved:

PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, null, fileName, binary, PdfStream.BEST_COMPRESSION);
fs.setUnicodeFileName(fileName, true);
writer.addFileAttachment(null, fs);

It will be better to add unicode checking to public static PdfFileSpecification fileEmbedded(PdfWriter writer, String filePath, String fileDisplay, byte[] fileStore, String mimeType, PdfDictionary fileParameter, int compressionLevel)?
For example like this:

fs.setUnicodeFileName(fileDisplay, !PdfEncodings.isPdfDocEncoding(fileDisplay));

@asturio
Copy link
Member

asturio commented May 2, 2021

You mean if the file name contains non-ASCII character (or at least non-Latin symbols) the file name won't be shown?

Pull request welcome.

RangerMak pushed a commit to RangerMak/OpenPDF that referenced this issue May 15, 2021
asturio pushed a commit that referenced this issue May 24, 2021
@asturio asturio added this to the 1.3.27 milestone May 24, 2021
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

Successfully merging a pull request may close this issue.

2 participants