Hi Ethan,
This is what i usually use to create appearance for PdfFields. Tell me if
it works for you
PdfField field = pPage->GetField(fieldNum);
if (field.GetType() == ePdfField_TextField) {
PoDoFo::PdfTextField textField = PoDoFo::PdfTextField(field);
NSString *value = aField.content;
textField.SetText(PoDoFo::PdfString(value.UTF8String));
textField.CreateFieldAppearance(&memDoc, value.UTF8String);
}
void PdfField::CreateFieldAppearance(PdfMemDocument *memDoc, const
PdfString&value)
{
if( !m_pWidget->HasAppearanceStream() )
{
PdfRect pageRect;
PdfPainter painter;
PoDoFo::PdfRect rect = this->GetWidgetAnnotation()->GetRect();
unsigned int width = rect.GetWidth();
unsigned int height = rect.GetHeight();
PdfRect pdfRect(0, 0, width, height);
PdfXObject xObj(pdfRect, memDoc);
painter.SetPage(&xObj);
painter.SetClipRect(pdfRect);
painter.Save();
painter.SetColor(221.0/255.0, 228.0/255.0, 1.0);
painter.FillRect(0, 0, width, height);
painter.Restore();
PdfFont *font = memDoc->CreateFont("Helvetica", true, false);
font->SetFontSize(15);
// Do the drawing
painter.SetFont(font);
painter.BeginText(0, 5);
painter.SetStrokeWidth(20);
painter.AddText(value);
painter.EndText();
painter.FinishPage();
//This is very important. Not only does it disable the editing.
Also does it correct the apperance issue on Adobe Readers
this->SetReadOnly(true);
//The Stream Object has to be saved to the annotation
PoDoFo::PdfDictionary dict;
dict.AddKey( "N", xObj.GetObject()->Reference() );
this->GetFieldObject()->GetDictionary().AddKey( "AP", dict );
}
}
Glad I could help
On Mon, Sep 23, 2013 at 9:54 PM, Ethan.Lee.W <[email protected]> wrote:
> **
> Hi,
> i found the appearance has been not created when i created the textfield.
> How can i create the appearance for the form fields and add font for the
> textfield?
>
> ------------------------------
> Ethan.Lee.W
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
> _______________________________________________
> Podofo-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/podofo-users
>
>
--
Regards,
Qamar Suleiman
قمرسلیمان
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users