Hi,
Fonts support only WinAnsi Encoding by default. So, if you need other
encodings, you have to specify them (and your font has to support them).
Take a look at PdfIdentityEncoding for example.
The PoDoFo example test/CreateTest shows also how to print Japanese text.
This should give you a start.
Best regards,
Dominik
On Wed, Aug 14, 2013 at 2:02 PM, <ma...@gayazov.ru> wrote:
> Hello, PoDoFo Team!
>
> Sorry for bad english.
> I'm write in PDF file, in 99% of the files okay. But i'm find 1 file,
> where the text is written, but not visible. this text i can copy from pdf
> and paste in "notepad".
> Please explain where I'm wrong.
>
> The file as an attachment.
> Code:
>
>
>
> void paintShtamp(const char* pdfFileName, const char* pdfOutFileName)
> {
> //инициализация размеров штампа
> double CONV_CONSTANT = 1.0; //коэффициент уменьшения
> int TABLE_WIDTH = 370; //ширина
> int charLen = 5;
> int ROW_HEIGHT = 12; //высота
> int TABLE_FIRST_COL_POS = 160;//ширина первого столба
> int TABLE_SECOND_COL_POS = 146;//ширина второго столба
>
> list<string> ecps;
> ecps.push_back("Кривошапкин М.К., ООО \"Новая заря\", Генеральный
> директорqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
> ecps.push_back("Прямокепкин К.Л., ООО \"Старый город\", менеджер по
> клинингу");
> ecps.push_back("Иванов К.Л., ООО \"Новый град\", бухгалтер");
>
> PoDoFo::PdfMemDocument pdf(pdfFileName );
> PoDoFo::PdfDocument * pPdf(&pdf);
>
> int ecpLen = 3;//
> if(ecpLen > 0)
> {
> std::string maxStr ="Кривошапкин М.К., ООО \"Новая заря\", Генеральный
> директорqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
> int maxLen = maxStr.length();
> TABLE_WIDTH = charLen * maxLen;
> PoDoFo::PdfPainter painter;
> PdfFont* pFont;
> const PoDoFo::PdfEncoding * pEncoding = new PoDoFo::PdfIdentityEncoding(0,
> 0xffff, true);
> pFont = pdf.CreateFont("Times", pEncoding);
>
> int tabLen = 4;
> if(ecpLen > 4) tabLen = ecpLen+1;
> PoDoFo::PdfTable table(1, tabLen);
> table.SetTableWidth((TABLE_WIDTH)*CONV_CONSTANT-5);
> table.SetTableHeight(ROW_HEIGHT*tabLen*CONV_CONSTANT);
> PoDoFo::PdfSimpleTableModel tableModel( table.GetCols(), table.GetRows() );
> tableModel.SetBorderWidth(0.3);
>
> tableModel.SetForegroundColor(PoDoFo::PdfColor(0.0, 0.0, 1.0));
> //line 1
> pFont->SetFontSize(10.0);
> tableModel.SetFont(pFont);
> tableModel.SetAlignment(ePdfVerticalAlignment_Center);
> list<string> ecps2;
>
>
> for (list<string>::const_iterator it = ecps.begin() ; it != ecps.end();
> ++it)
> {
> string tmp;
> sbis::Utf8Encode( (*it), tmp, false );
> ecps2.push_back(tmp);
> }
>
>
> //tableModel.SetWordWrapEnabled(true);
> tableModel.SetText( 0, 0, L"Подписано электронно" );//2Подписано электронно
> pFont->SetFontSize(8.0);
> tableModel.SetFont(pFont);
>
>
>
>
> PoDoFo::PdfColor color = PdfColor( 1.0, 0.0, 0.0 );
>
> tableModel.SetBackgroundColor(color);
>
> int pos = 1;
> for (auto it = ecps2.begin(), et = ecps2.end() ; it != et; ++it)
> {
> tableModel.SetText( 0, pos, PoDoFo::PdfString((const
> PoDoFo::pdf_utf8*)(it->c_str())));//2
> pos++;
> }
> tableModel.SetBorderEnabled(false);
> table.SetModel( &tableModel );
>
> for (int pn = 0; pn < pdf.GetPageCount(); ++pn) {
>
> PoDoFo::PdfPage* page = pdf.GetPage(pn);
> int rotation = page->GetRotation();
>
> //size correction
> {
> double pageWidth = rotation == 90 ? page->GetPageSize().GetHeight() :
> page->GetPageSize().GetWidth();;
> if(pageWidth < TABLE_WIDTH ) {
> pFont->SetFontSize(8.0*(pageWidth/TABLE_WIDTH));
> tableModel.SetFont(pFont);
> TABLE_WIDTH = pageWidth*0.9;
> }
> }
>
> painter.SetPage( page );
>
> double dX = page->GetPageSize().GetWidth() - (TABLE_WIDTH)*CONV_CONSTANT
> - 15.0;
> double dY = ROW_HEIGHT*tabLen*CONV_CONSTANT + 15.0;
>
> if(rotation == 90)
> {
> int height = page->GetPageSize().GetWidth();
> int width = page->GetPageSize().GetHeight()-TABLE_WIDTH*CONV_CONSTANT-dX -
> 15;
> painter.SetTransformationMatrix(0.0, 1, -1, 0.0, height, width);
> painter.Save();
> }
> table.Draw(dX+5, dY, &painter);
> painter.SetStrokingColor( 0.0, 0.0, 1.0 );
> painter.SetStrokeWidth(0.3);
> painter.DrawRect( dX, dY+4, (TABLE_WIDTH)*CONV_CONSTANT+4,
> -ROW_HEIGHT*tabLen*CONV_CONSTANT-8 );
> painter.DrawRect( dX+2, dY+2, (TABLE_WIDTH)*CONV_CONSTANT, -
> ROW_HEIGHT*tabLen*CONV_CONSTANT-4 );
> painter.FinishPage();
> }
> }
> pdf.Write(pdfOutFileName);
> }
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users
>
>
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users