[gdal-dev] Encoding when creating pdf

Jorge Gustavo Rocha jgr at osgeopt.pt
Sun Nov 15 09:27:39 PST 2020


Hi Aneta,

I didn't try on the command line. But I've tried with QGIS (QGIS uses
GDAl to generate PDFs).

I was able to create a PDF with accent characters everywhere. Check the
attached PDF.

I've used a layer name with accents; I've used a label with accents.
I've also used as attribute field name with accents and the value with
accents. The label is displayed properly on the feature.

I'm using GDAL 3.3.0dev, compiled with --with-poppler. I would recommend
a more recent version of GDAL (ver. >= 3.1.0).

Regards,

Jorge

Às 08:26 de 09/11/20, Aneta Muslić escreveu:
> Yes, it does.
> The problem is that gdal uses ansi as a default encoding when given font
> in label, and that cannot be changed.
> 
> 
> ------------------------------------------------------------------------
> *From:* Richard Greenwood <richard.greenwood at gmail.com>
> *Sent:* Thursday, November 5, 2020 4:27 PM
> *To:* Aneta Muslić <a.muslic at outlook.com>
> *Cc:* gdal-dev at lists.osgeo.org <gdal-dev at lists.osgeo.org>
> *Subject:* Re: [gdal-dev] Encoding when creating pdf
>  
> Do your shapefiles include a code page file (*.cpg)? If not, maybe that
> would help.
> 
> On Wed, Nov 4, 2020 at 2:57 AM Aneta Muslić <a.muslic at outlook.com
> <mailto:a.muslic at outlook.com>> wrote:
> 
>     Hello,
> 
>     I am using gdal version 2.4.4 in my c# app.
>     As a part of my project I am creating pdf with gdal_translate
>     command. GDAL translate command is 
>     /"gdal_translate  --config SHAPE_ENCODING "utf-8" -of PDF -tr 0.001
>     0.001 -a_srs EPSG:3765 Granice.tif Sisacko_moslavacka_zupanija3.pdf
>     -co OGR_DATASOURCE=Extent.vrt"./
>     /
>     /
>     Part of vrt file that displays labels is:
>     /<OGRVRTLayer name="SHPCounties">/
>     /<SrcDataSource relativeToVRT="0">MSSQL: driver={SQL Server Native
>     Client 11.0};/
>     /server=xxx;uid=xx;pwd=xx;database=HAPIH;/
>     /Integrated Security=False;MARS_Connection=yes</SrcDataSource>/
>     /<SrcLayer>SHPCounties</SrcLayer>/
>     /<LayerSRS>EPSG:3765</LayerSRS>        /
>     /<SrcSQL>/
>     /select Geometry.STCentroid() as pointPolygonCounties,/
>     /CAST(Name AS varchar(100)) COLLATE Croatian_CI_AI AS NameCollated,/
>     /'LABEL(f:"Times New Roman",t:{NameCollated},c:#000000,s:40pt)' AS
>     OGR_STYLE /
>     /FROM SHPCounties/
>     /</SrcSQL>/
>     /<GeometryType>wkbPoints</GeometryType> /
>     /<GeometryField name="pointPolygonCounties" />/
>     /</OGRVRTLayer>
>     /
> 
>     My labels have special characters (č and ć). I defined encoding to
>     utf-8 and gdal-config as utf-8 but in generated pdf under fonts I
>     can see that the font used is Times New Roman with encoding ansi,
>     and characters č and ć are replaced with c because ansi doesn't
>     support those letters. I tried writing just the letter 'č' to pdf so
>     I can eliminate that the problem is in database but it is replaced
>     with something else in pdf,  also I tried using html entity for
>     those letters but it doesn't help.
> 
>     I would like to know how can I define in label options of vrt file
>     for it to use font with custom encoding and not ansi encoding so it
>     can display my special characters or there is another way for me to
>     display those special characters. 
> 
>     Thank you.
> 
>     _______________________________________________
>     gdal-dev mailing list
>     gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>     https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 
> 
> -- 
> Richard W. Greenwood, PLS
> www.greenwoodmap.com <http://www.greenwoodmap.com>
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 

-- 
OSGeo Portugal
NIF: 509588190
email: geral at osgeopt.pt
https://www.osgeopt.pt/

Próximo evento: SASIG 2017, 20 a 22 de novembro, Porto
Mais informações: http://osgeopt.pt/sasig2017/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/pdf
Size: 23537 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201115/f3fc0b2a/attachment-0001.pdf>


More information about the gdal-dev mailing list