Dear Sir / Madam,

how to set pdf text

        PdfMemDocument doc("D:\\sample pdf\\test.pdf");
        PdfPainter     painter;
        PdfPage*       pPage;
        PdfRect        rect;
        PdfFont*       pFont = doc.CreateFont("Times New Roman", new 
PdfIdentityEncoding(0, 0xffff, true));
        int            i;

        for (i = 0; i<doc.GetPageCount(); i++)
        {
                pPage = doc.GetPage(i);

                if (!pPage)
                        PODOFO_RAISE_ERROR(ePdfError_InvalidHandle);

                PdfExtGState gstate(&doc);
                rect = pPage->GetPageSize();
                painter.SetPage(pPage);
                gstate.SetFillOpacity(0.5);
                gstate.SetRenderingIntent(ePdfRenderingIntent_Saturation);
                gstate.SetBlendMode(ePdfBlendMode_Darken);
                painter.SetExtGState(&gstate);
                painter.Save();
                painter.SetStrokingColor(1.0, 0.0, 0.0);
                painter.SetStrokeWidth(5);
                painter.Rectangle(rect.GetWidth() - 205, rect.GetHeight() 
- 55, 200, 50, 10, 10);
                painter.DrawLine(0.0, 0.0, rect.GetWidth(), 
rect.GetHeight());
                //painter.SetTransformationMatrix(0.707, 0.707, -0.707, 
0.707, rect.GetWidth()/3.0, rect.GetHeight()/2.0);
                // First the transport.
                painter.SetTransformationMatrix(1, 0, 0, 1, 
rect.GetWidth() / 3.0, rect.GetHeight() / 2.0);
                // Second make angles.
                painter.SetTransformationMatrix(0.707, 0.707, -0.707, 
0.707, 0, 0);
                // Third make scale.
                //painter.SetTransformationMatrix(100, 0, 0, 100, 0, 0);
                PdfString text(L"hello");
                painter.Restore();
                painter.FinishPage();
        }

        doc.Write("D:\\sample pdf\\test2.pdf");

"hello" not appear in pdf, where is wrong?

if copy from https://sourceforge.net/p/podofo/mailman/message/30762385/
symbol appear, not text "hello".
if change to doc.CreateFont("Arial", new PdfIdentityEncoding(0, 0xffff, 
true)) also same


        PdfMemDocument doc("D:\\sample pdf\\test.pdf");
        PdfPainter     painter;
        PdfPage*       pPage;
        PdfRect        rect;
        PdfFont* pFont = doc.CreateFont("Times New Roman", new 
PdfIdentityEncoding(0, 0xffff, true));
        pFont->SetFontSize(72);

        for (int i = 0; i<doc.GetPageCount(); i++)
        {
                pPage = doc.GetPage(i);

                if (!pPage)
                        PODOFO_RAISE_ERROR(ePdfError_InvalidHandle);

                rect = pPage->GetPageSize();

                //Draw simple shapes.
                painter.SetPage(pPage);
                painter.SetStrokingColor(1.0, 0.0, 0.0);
                painter.SetStrokeWidth(5);
                painter.Rectangle(rect.GetWidth() - 205, rect.GetHeight() 
- 55, 200, 50, 10, 10);
                painter.DrawLine(0.0, 0.0, rect.GetWidth(), 
rect.GetHeight());

                //Draw text as watermark. 
                painter.SetFont(pFont);
                painter.SetColor(PdfColor(1.0, 0, 0));
 
                PdfExtGState gstate(&doc);
                //gstate.SetFillOpacity(1.0f * i / doc.GetPageCount());
                gstate.SetFillOpacity(0.5);
                gstate.SetRenderingIntent(ePdfRenderingIntent_Saturation);
                gstate.SetBlendMode(ePdfBlendMode_Darken);
                painter.SetExtGState(&gstate);
                painter.Save(); 
                painter.SetTransformationMatrix(1, 0, 0, 1, 
rect.GetWidth() / 2, rect.GetHeight() / 2);                     // First 
the transport. 
                painter.SetTransformationMatrix(0.707, 0.707, -0.707, 
0.707, 0, 0);                                                           // 
Second make angles. 
                //painter.SetTransformationMatrix(100, 0, 0, 100, 0, 0);   
                                                        // Third make 
scale.
                // add text watermark here in Japanese
                PdfString text(L"こんにちは");
                // add text watermark here in Chinese
                //PdfString text(L"?好");
                // add text watermark here in English.
                //PdfString text(L"Hello");
                painter.DrawText(0, 0, text);
                painter.Restore();
                painter.FinishPage();
                painter.SetPage(pPage);
                painter.FinishPage();
        }

        doc.Write("D:\\sample pdf\\test2.pdf");

the symbol also very small.

if Japanese, try using "MS Mincho Regular"

no text or symbol display.
Please advice.

Thanks you very much.


With Regards,
Tang
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to