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 :/
-------------------------------------------------------------------------
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