- // load the pdftitle etc. as hypersetup, otherwise you'll get
- // LaTeX-errors when using non-latin characters
- string hyperset;
- if (!title.empty())
- hyperset += "pdftitle={" + title + "},";
- if (!author.empty())
- hyperset += "\n pdfauthor={" + author + "},";
- if (!subject.empty())
- hyperset += "\n pdfsubject={" + subject + "},";
- if (!keywords.empty())
- hyperset += "\n pdfkeywords={" + keywords + "},";
- if (!quoted_options.empty()){
- hyperset += "\n ";
- hyperset += quoted_options_get();
+ if (!hyperset.empty())
+ opt += "\\hypersetup{" + hyperset + "}\n";
+ } else {
+ // only in case hyperref is already loaded by the current text class
+ // try to put it into hyperset
+ //
+ // FIXME: rename in this case the PDF settings dialog checkbox
+ // label from "Use Hyperref" to "Customize Hyperref Settings"
+ // as discussd in bug #6293
+ opt = "\\hypersetup{" + rtrim(opt + hyperset, ",") + "}\n";
+ }
+
+ // hyperref expects LICR macros for non-ASCII chars.
+ // Usually, "(lua)inputenc" converts the input to LICR, with XeTeX utf-8 works, too.
+ // As hyperref provides good coverage for \inputencoding{utf8}, we can try
+ // this if the current input encoding does not support a character.
+ // FIXME: don't use \inputencoding if "inputenc" is not loaded (#9839).
+ if (need_unicode && enc && enc->iconvName() != "UTF-8") {
+ if (runparams.flavor != OutputParams::XETEX)
+ os << "\\inputencoding{utf8}\n";
+ os << setEncoding("UTF-8");
+ }
+ // If hyperref is loaded by the document class, we output
+ // \hypersetup \AtBeginDocument if hypersetup is not (yet)
+ // defined. In this case, the class loads hyperref late
+ // (see bug #7048).
+ if (hyperref_already_provided && !opt.empty()) {
+ os << "\\ifx\\hypersetup\\undefined\n"
+ << " \\AtBeginDocument{%\n "
+ << from_utf8(opt)
+ << " }\n"
+ << "\\else\n "
+ << from_utf8(opt)
+ << "\\fi\n";
+ } else
+ os << from_utf8(opt);
+ if (need_unicode && enc && enc->iconvName() != "UTF-8") {
+ os << setEncoding(enc->iconvName());
+ if (runparams.flavor != OutputParams::XETEX)
+ os << "\\inputencoding{" << from_ascii(enc->latexName()) << "}\n";