Knowledge Base - Draw bitmap with transparent background (iOS)

You can use the below code to draw a bitmap with transparent background, drawing the image as page content:

    // Get page

    PDFPage *page = [m_doc page:0];


    // Create page content

    PDFPageContent *content = [[PDFPageContent alloc] init];


    // Get the image to add

    UIImage *img = [UIImage imageNamed:@"image"];


    // Create a Doc Image instance

    PDFDocImage *image = [m_doc newImage:img.CGImage :YES];


    // Add the image as page resource

    PDF_PAGE_IMAGE rimg = [page addResImage:image];

    [content gsSave];


    // Set the matrix (image position/size on page)

    PDFMatrix *matrix = [[PDFMatrix alloc] init:200 :200 :100 :100];

    [content gsCatMatrix:matrix];

    matrix = nil;


    // Draw the image on page content

    [content drawImage:rimg];

    [content gsRestore];


    // Add the content on the page

    [page addContent:content :false];


    // Save the file

    [m_doc save]; 

Applies To

RadaeePDF SDK for iOS


Created : 2018-02-07 11:20:18, Last Modified : 2018-02-07 11:20:18