Hi,

PoDoFo does not support direct utf-8 output currently . All strings have to be 
in WinAnsiEncoding at the moment. If not you have to create the relevant keys 
in the font dictionary of the PdfFont yourself. Please consult the PDF 
specification

But you are not lost, I have the code for simple UTF-8 support with TrueType 
fonts almost ready on my disc. I intend to commit it by next weekend. Your 
code should work then with minimal modifications.

best regards,
        Dom

Am Montag, 7. Januar 2008 schrieb Paweł Ciejka:
> Hi, i am developing an application with saving to pdf support and i ve got
> a question. I have to save unicode (utf-8) characters to this pdf and i
> can't get this working.  This characters are read(); from file card.txt
> which is utf-8 encoded. My sample code look like this:
>
> //----------------------code-----------------
> #include <podofo/podofo.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
>
> using namespace PoDoFo;
>
> int main(int argc,char *argv[])
> {
> int fd = 0;
> pdf_utf8 buffer[4096];
> int bytes;
>
> PdfPage* pPage = NULL;
> PdfPainter painter;
> PdfFont* pFont = NULL;
> PdfStreamedDocument *document = NULL;
> PdfString string;
> memset(buffer,0,4096);
> if(!(fd = open("card.txt",O_RDONLY)))
> {
> printf("error\r\n");
> return -1;
> }
> if(!(document = new PdfStreamedDocument("card.pdf")))
> {
> printf("error\r\n");
> return -1;
> }
> if(!(pFont = document->CreateFont("Arial")))
> {
> printf("error\r\n");
> return -1;
> }
> pFont->SetFontSize(18.0);
> if(!(pPage =
> document->CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4))))
> {
> printf("error\r\n");
> return -1;
> }
> painter.SetPage( pPage );
> painter.SetFont( pFont );
> while((bytes = read(fd,buffer,4096)) > 0)
> {
> string = PdfString(buffer,bytes);
> painter.DrawText(56.59, pPage->GetPageSize().GetHeight() - 56.69,string);
> memset(buffer,0,4096);
> }
> painter.FinishPage();
> document->Close();
> close(fd);
> delete document;
> return 0;
> }
> //---------EOF---------------------------------
>
> thanks for help because i am getting close to deadline :/



-- 
**********************************************************************
Dominik Seichter - [EMAIL PROTECTED]
KRename  - http://www.krename.net  - Powerful batch renamer for KDE
KBarcode - http://www.kbarcode.net - Barcode and label printing
PoDoFo - http://podofo.sf.net - PDF generation and parsing library
SchafKopf - http://schafkopf.berlios.de - Schafkopf, a card game,  for KDE
Alan - http://alan.sf.net - A Turing Machine in Java
**********************************************************************

Attachment: signature.asc
Description: This is a digitally signed message part.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to