Sanne Faurholt
Sanne Faurholt

Reputation: 63

How do I get aspPdf to write special characters like æ, ø and å?

I am using aspPdf to convert a html page into a pdf file. And it is working fine, except from the special characters æ, ø and å.

I have this:

<!--#include file="include/connectOpen.asp"-->
<!DOCTYPE html>
<html lang="da">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<%

Response.Charset = "utf-8"
Response.ContentType = "text/html; charset=utf-8"

booking_id = 15
vikar_id = 1

Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument

importUrl = "https://www.vikarbooking.com/kontrakter/template.asp?bookingId=" &    booking_id & "&vikarId=" & vikar_id
Doc.ImportFromUrl importUrl, "scale=0.6; hyperlinks=true; drawbackground=true;"

Filename = Doc.Save( Server.MapPath("importfromurl.pdf"), false ) 
Response.Write Server.MapPath("importfromurl.pdf") & " - Done!"
%>
</body>
</html>

And the file Im converting is like this:

<%
Response.Charset = "utf-8"
Response.ContentType = "text/html; charset=utf-8"
%>
<!DOCTYPE html>
<html lang="da">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

<style>
    body {
        font-family: Arial, sans-serif;
        background-color: #fff;
        font-weight: 300;
        font-size:20pt;
    }
</style>
</head>
<body>
Some text here with æ, ø and å
</body>
</html>

What can I do to get æ, ø and å written to the pdf?

Upvotes: 0

Views: 67

Answers (1)

John
John

Reputation: 4663

First of all I recommend you add Response.CodePage = 65001 along with your Charset and ContentType settings. See this blog for more details. https://www.hanselman.com/blog/internationalization-and-classic-asp

Second, if your international characters are hardcoded into a page, make sure the page is saved as UTF-8 rather than ANSI.

There are plenty of answers on SO and elsewhere which cover both of these, however I think there might also be a setting specific to aspPDF. I haven't used it, however I have used another Persits product - Persits Upload - and I had to specifically set the Upload object to use utf-8 as follows, otherwise it defaults to Windows-1252 - it doesn't inherit the Response.CodePage setting from earlier in the page.

Set Upload = Server.CreateObject("Persits.Upload")
Upload.CodePage = 65001

I'm guessing that there is something similar happening here. Looking at the User Guide I suggest you try:

Doc.ImportFromUrl importUrl, "CodePage=65001; scale=0.6; hyperlinks=true; drawbackground=true;"

Link to relevant page in user guide - https://www.asppdf.com/object_document.html

Upvotes: 1

Related Questions