1
주석의 값을 설정하기 위해 PdfAnnotation.SetContents를 사용하고 있습니다. 주석이 FreeText 유형 인 경우에만이 방법이 올바르게 작동하고 값이 PDF 리더에 표시됩니다. . 위젯 유형의 경우, 값은 pdf 사전의 내용으로 설정되지만 표시되지 않습니다. 위젯의 값을 설정할 수있는 방법이 있습니까?Podofo를 사용하여 PDF의 위젯 업데이트
주석의 값을 설정하기 위해 PdfAnnotation.SetContents를 사용하고 있습니다. 주석이 FreeText 유형 인 경우에만이 방법이 올바르게 작동하고 값이 PDF 리더에 표시됩니다. . 위젯 유형의 경우, 값은 pdf 사전의 내용으로 설정되지만 표시되지 않습니다. 위젯의 값을 설정할 수있는 방법이 있습니까?Podofo를 사용하여 PDF의 위젯 업데이트
콘텐츠를 표시하려면 Appearance (AP) 사전을 설정해야합니다.
이
은 사용할 수 있습니다 : 코드 위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();
// make rotation
painter.Save();
/***********************************************************************************/
// Rotation Logic
double angle = this->GetPage()->GetRotation();
if (angle) {
double radAngle = angle * M_PI/180;
int cosA = (int)cos(radAngle);
int sinA = (int)sin(radAngle);
double translateY = rect.GetWidth(); // The View goes out of the bound, sits on top
painter.SetTransformationMatrix(cosA, sinA, -sinA, cosA, translateY, 0);
}
/***********************************************************************************/
PdfFont *font = memDoc->CreateFont("Helvetica", true, false);
font->SetFontSize(15);
// Do the drawing
painter.SetFont(font);
painter.BeginText(10, 5);
painter.SetStrokeWidth(20);
painter.AddText(value);
painter.EndText();
painter.FinishPage();
// This is very important. Not only does it disable the editing.
// Also it does correct the appearance 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);
}
}
가 잘 작동된다. @ iphonic 및 @qamar 외모에 이미지를 추가하는 방법을 알려주십시오. –