Adding note to PDF file

103 views
Skip to first unread message

Wilson Wade

unread,
Aug 4, 2021, 9:44:37 AM8/4/21
to pdfium
Hi all, I try to add notes to the pdf file, but I failed.

Below is my code:

PDFDocument *pdfDocument = createNewPDFDocument();
PDFPage *pdfPage = createNewPDFPage(pdfDocument, 0, 800, 1200);

FPDF_ANNOTATION newAnnot = FPDFPage_CreateAnnot(pdfPage->fpdfPage, FPDF_ANNOT_HIGHLIGHT);
FPDFAnnot_SetColor(newAnnot, FPDFANNOT_COLORTYPE_Color, /*R=*/250, /*G=*/210, /*B=*/0, /*A=*/255);

FS_RECTF rectF{100, 1100, 300, 200};
FS_QUADPOINTSF quadPoints;
quadPoints.x1 = 100;
quadPoints.y1 = 1100;

quadPoints.x2 = 300;
quadPoints.y2 = 1100;

quadPoints.x3 = 100;
quadPoints.y3 = 200;

quadPoints.x4 = 300;
quadPoints.y4 = 200;

FPDFAnnot_SetAP(newAnnot, FPDF_ANNOT_APPEARANCEMODE_NORMAL, charStringToFPDF_WIDESTRING("Hello Note!"));

FPDFAnnot_AppendAttachmentPoints(newAnnot, &quadPoints);
FPDFAnnot_SetRect(newAnnot, &rectF);

FPDFPage_CloseAnnot(newAnnot);

FPDFPage_GenerateContent(pdfPage->fpdfPage);

savePDFDocumentToFile(pdfDocument, fd);
closePDFDocument(pdfDocument);


I got the result like file 1, But the result I want is like file 2. Any help is much appreciated.


file_1.pdf
file_2.pdf
Reply all
Reply to author
Forward
0 new messages