Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. FPDF_InitLibrary();
  2. FPDF_STRING test_doc = "myTest.pdf";
  3. FPDF_DOCUMENT doc = FPDF_LoadDocument(test_doc, NULL);
  4. if (!doc) {
  5. qWarning() << " error loading PDF file";
  6. return 1;
  7. }
  8. FPDF_PAGE page = FPDF_LoadPage(doc, 0);
  9. if (!page) {
  10. qWarning() << " error loading first page";
  11. return 1;
  12. }
  13.  
  14. FPDF_ANNOTATION highlightAnnot = FPDFPage_CreateAnnot(page, FPDF_ANNOT_HIGHLIGHT);
  15.  
  16. if (highlightAnnot) {
  17. // Set the annotation rectangle.
  18. FS_RECTF rect;
  19. rect.left = 72;
  20. rect.bottom = 504;
  21. rect.right = 132;
  22. rect.top = 520;
  23. if(!FPDFAnnot_SetRect(highlightAnnot, &rect)) {
  24. qWarning() << " error in FPDFAnnot_SetRect()";
  25. }
  26. // When using AP this function should not be used. See doc in FPDF_annot.h
  27. if(!FPDFAnnot_SetColor(highlightAnnot, FPDFANNOT_COLORTYPE_Color, 255, 255, 0, 255)) {
  28. qWarning() << " error in FPDFAnnot_SetColor()";
  29. }
  30. // Append a new set of quadpoints.
  31. FS_QUADPOINTSF new_quadpoints;
  32. new_quadpoints.x1 = 72.f;
  33. new_quadpoints.y1 = 520.f;
  34. new_quadpoints.x2 = 132.f;
  35. new_quadpoints.y2 = 520.f;
  36. new_quadpoints.x3 = 72.f;
  37. new_quadpoints.y3 = 504.f;
  38. new_quadpoints.x4 = 132.f;
  39. new_quadpoints.y4 = 504.f;
  40. if(!FPDFAnnot_AppendAttachmentPoints(highlightAnnot, &new_quadpoints)) {
  41. qWarning() << " error FPDFAnnot_AppendAttachmentPoints()";
  42. }
  43. }
  44. FPDF_ClosePage(page);
  45.  
  46. // writing file with FPDF_SaveAsCopy()
  47. ...
  48. FPDF_DestroyLibrary();
  49. return retCode;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement