Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FPDF_InitLibrary();
- FPDF_STRING test_doc = "myTest.pdf";
- FPDF_DOCUMENT doc = FPDF_LoadDocument(test_doc, NULL);
- if (!doc) {
- qWarning() << " error loading PDF file";
- return 1;
- }
- FPDF_PAGE page = FPDF_LoadPage(doc, 0);
- if (!page) {
- qWarning() << " error loading first page";
- return 1;
- }
- FPDF_ANNOTATION highlightAnnot = FPDFPage_CreateAnnot(page, FPDF_ANNOT_HIGHLIGHT);
- if (highlightAnnot) {
- // Set the annotation rectangle.
- FS_RECTF rect;
- rect.left = 72;
- rect.bottom = 504;
- rect.right = 132;
- rect.top = 520;
- if(!FPDFAnnot_SetRect(highlightAnnot, &rect)) {
- qWarning() << " error in FPDFAnnot_SetRect()";
- }
- // When using AP this function should not be used. See doc in FPDF_annot.h
- if(!FPDFAnnot_SetColor(highlightAnnot, FPDFANNOT_COLORTYPE_Color, 255, 255, 0, 255)) {
- qWarning() << " error in FPDFAnnot_SetColor()";
- }
- // Append a new set of quadpoints.
- FS_QUADPOINTSF new_quadpoints;
- new_quadpoints.x1 = 72.f;
- new_quadpoints.y1 = 520.f;
- new_quadpoints.x2 = 132.f;
- new_quadpoints.y2 = 520.f;
- new_quadpoints.x3 = 72.f;
- new_quadpoints.y3 = 504.f;
- new_quadpoints.x4 = 132.f;
- new_quadpoints.y4 = 504.f;
- if(!FPDFAnnot_AppendAttachmentPoints(highlightAnnot, &new_quadpoints)) {
- qWarning() << " error FPDFAnnot_AppendAttachmentPoints()";
- }
- }
- FPDF_ClosePage(page);
- // writing file with FPDF_SaveAsCopy()
- ...
- FPDF_DestroyLibrary();
- return retCode;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement