Skip to content

Image embedding API

Georgiy Sgibnev requested to merge georgiy/poppler:master into master
  1. Image embedding API. Supported formats: PNG, JPEG.
  2. Tests for image embedding API.
  3. API to create a signature with background image.

sign-example

Example

bool createSignatureWithImage(PDFDoc &doc)
{
    const int PAGE_NUM = 1;
    const double fontSize = 11.0;
    const std::string signatureText = "\n\n  My signature";
    const char *outputPath = "signed.pdf";
    const char *certificate = "Imported Certificate";
    const char *password = "password";
    const std::string imagePath = "signature.png";
    GooString fieldName = GooString("my-signature-field");

    PDFRectangle rect = { 337.3, 550.3, 441.5, 619.1 };
    std::unique_ptr<GooString> gSignatureText = std::unique_ptr<GooString>(utf8ToUtf16WithBom(signatureText));
    std::unique_ptr<AnnotColor> fontColor = std::unique_ptr<AnnotColor>(new AnnotColor(0.0, 0.57, 0.87));
    return doc.sign(outputPath, certificate, password, fieldName.copy(), PAGE_NUM,
                    rect, *gSignatureText, GooString(), fontSize,
                    std::move(fontColor), 0, {}, {}, nullptr, nullptr, imagePath);
}

Files: signature.png, signed.pdf

Edited by Georgiy Sgibnev

Merge request reports