Problem with odd chars in pdf

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with odd chars in pdf

list
Can someone confirm, or point to a solution, why certain chars are omitted from a pdf created by Lasso. The name Bečević is shortened to Beevi in MacOS X, Windows and Linux. Running 8.5.6 and 8.5.5 with Bils adjusted pdf.jar.

Here's a complete test page to try on:

<?LassoScript
var('pagetype' = 'A4',
        'pageheight' = 842, // points
        'pagewidth' = 595);

// Create the pdf_doc object
var( 'pdf' = pdf_doc( -size = $pagetype,
        -margins = array( 25.0, 25.0, 25.0, 25.0), -nocompress));

// Setting font variables with some of the standard fonts available
var('HelvBold14Black' = (pdf_font:
        -face = 'Helvetica-Bold',
        -size = 14,
        -color = '#000000'));

var('TimesPlain10' = (pdf_font:
        -face = 'Times-Roman',
        -size = 10)); // without a color param Lasso uses default black color

// Adding the problem text Bečević
$pdf -> add(pdf_text( 'Helvetica-Bold 14 points.\rBečević\r\r',
                -font = $HelvBold14Black,
        -leading = 18));

$pdf -> add(pdf_text( 'Times 10 points.\rBečević\r\r',
                -font = $TimesPlain10,
                -leading = 14));

// Using no font variable defaults to Helvetica 12 points
$pdf -> add(pdf_text( 'Helvetica 12 points.\rBečević',
                -leading = 16));

// Finally close the pdf_doc and serve it
$pdf -> close;
pdf_serve( -content = $pdf, -file = 'Bečević_testing.pdf');

?>

Save it as a UTF-8 with BOM and try it.

HDB
Jolle
--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Problem with odd chars in pdf

Jonathan Vanherpe (T & T NV)
I've had the same problem, but never really found a solution (well,
except for using wkhtmltopdf to do these kinds of things instead of
trying to use Lasso)

Jonathan

[hidden email] wrote:

> Can someone confirm, or point to a solution, why certain chars are omitted from a pdf created by Lasso. The name Bečević is shortened to Beevi in MacOS X, Windows and Linux. Running 8.5.6 and 8.5.5 with Bils adjusted pdf.jar.
>
> Here's a complete test page to try on:
>
> <?LassoScript
> var('pagetype' = 'A4',
> 'pageheight' = 842, // points
> 'pagewidth' = 595);
>
> // Create the pdf_doc object
> var( 'pdf' = pdf_doc( -size = $pagetype,
> -margins = array( 25.0, 25.0, 25.0, 25.0), -nocompress));
>
> // Setting font variables with some of the standard fonts available
> var('HelvBold14Black' = (pdf_font:
> -face = 'Helvetica-Bold',
> -size = 14,
> -color = '#000000'));
>
> var('TimesPlain10' = (pdf_font:
> -face = 'Times-Roman',
> -size = 10)); // without a color param Lasso uses default black color
>
> // Adding the problem text Bečević
> $pdf ->  add(pdf_text( 'Helvetica-Bold 14 points.\rBečević\r\r',
> -font = $HelvBold14Black,
> -leading = 18));
>
> $pdf ->  add(pdf_text( 'Times 10 points.\rBečević\r\r',
> -font = $TimesPlain10,
> -leading = 14));
>
> // Using no font variable defaults to Helvetica 12 points
> $pdf ->  add(pdf_text( 'Helvetica 12 points.\rBečević',
> -leading = 16));
>
> // Finally close the pdf_doc and serve it
> $pdf ->  close;
> pdf_serve( -content = $pdf, -file = 'Bečević_testing.pdf');
>
> ?>
>
> Save it as a UTF-8 with BOM and try it.
>
> HDB
> Jolle
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>


--
Jonathan Vanherpe - Tallieu & Tallieu nv - [hidden email]

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Problem with odd chars in pdf

stevepiercy
In reply to this post by list
Confirmed on Mac OS X, 10.5.8, LP 8.5.6.

However, I don't think this is actually a bug.  It is a matter
of finding the correct font face or file that supports the
character encoding you require, then setting the proper
character encoding.  Helvetica supports a character encoding
that might work for your PDFs, so you might try that encoding on
other fonts too.  You might also try to convert fonts with fondu.

This works for me.

     var('pagetype' = 'A4',
         'pageheight' = 842, // points
         'pagewidth' = 595);

     // Create the pdf_doc object
     var('pdf') = pdf_doc(
         -size = $pagetype,
         -margins = array( 25.0, 25.0, 25.0, 25.0),
         -nocompress);

     var('helvetica10') = pdf_font(
         -face = 'Helvetica',
         -encoding='cp1257',
         -size = 10);

     // Adding the problem text Bečević
     $pdf -> add(pdf_text('Helvetica 10 points.\rBečević\r\r',
             -font = $helvetica10,
             -leading = 14));

     // Finally close the pdf_doc and serve it
     $pdf -> close;
     pdf_serve(-content = $pdf, -file = 'Bečević_testing.pdf');

What is so frustrating is that there is no obvious encoding code
to use, based on the $myfont->getsupportedencodings member tag.  
I had to find a TT font file and use that to get an array of
supported encodings, then make educated guesses on the actual
code to use in the pdf_font declaration to set the proper encoding.

     $helvetica10->istruetype;
     $helvetica10->getsupportedencodings;
     $helvetica10->getencoding;

Ah, found it here:
http://api.itextpdf.com/com/itextpdf/text/pdf/BaseFont.html

Looks like the codes are:
Cp1250
Cp1252
Cp1257
MacRoman
WINANSI (same as Cp1252)

--steve


On 6/29/10 at 11:09 AM, [hidden email] pronounced:

>Can someone confirm, or point to a solution, why certain chars
>are omitted from a pdf created by Lasso. The name Bečević is
>shortened to Beevi in MacOS X, Windows and Linux. Running 8.5.6
>and 8.5.5 with Bils adjusted pdf.jar.
>
>Here's a complete test page to try on:
>
><?LassoScript
>var('pagetype' = 'A4',
>'pageheight' = 842, // points
>'pagewidth' = 595);
>
>// Create the pdf_doc object
>var( 'pdf' = pdf_doc( -size = $pagetype,
>-margins = array( 25.0, 25.0, 25.0, 25.0), -nocompress));
>
>// Setting font variables with some of the standard fonts available
>var('HelvBold14Black' = (pdf_font:
>-face = 'Helvetica-Bold',
>-size = 14,
>-color = '#000000'));
>
>var('TimesPlain10' = (pdf_font:
>-face = 'Times-Roman',
>-size = 10)); // without a color param Lasso uses default black color
>
>// Adding the problem text Bečević
>$pdf -> add(pdf_text( 'Helvetica-Bold 14 points.\rBečević\r\r',
>-font = $HelvBold14Black,
>-leading = 18));
>
>$pdf -> add(pdf_text( 'Times 10 points.\rBečević\r\r',
>-font = $TimesPlain10,
>-leading = 14));
>
>// Using no font variable defaults to Helvetica 12 points
>$pdf -> add(pdf_text( 'Helvetica 12 points.\rBečević',
>-leading = 16));
>
>// Finally close the pdf_doc and serve it
>$pdf -> close;
>pdf_serve( -content = $pdf, -file = 'Bečević_testing.pdf');
>
>?>
>
>Save it as a UTF-8 with BOM and try it.
>
>HDB
>Jolle
>--
>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>Manage your subscription: http://www.ListSearch.com/Lasso/
>
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Problem with odd chars in pdf

list
Well, look at that. You found the missing link!

Adding that to the actual report page I had trouble with solved it. Wonder if it introduces other unknown issues...
Thanks, Steve!

HDB
Jolle


29 jun 2010 kl. 13.18 skrev Steve Piercy - Web Site Builder:

>    var('helvetica10') = pdf_font(
>        -face = 'Helvetica',
>        -encoding='cp1257',
>        -size = 10);


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/