Frequently Asked Question

Change page size using advanced properties (iOS)
Last Updated 11 months ago

Using the Advanced properties, you can change the page dimensions, check the below code:

Note: a premium license is needed.

- (void)setBoxHeight:(int)height width:(int)width forPage:(int)pageno
{
    PDFPage *page = [m_doc page:pageno];
    PDFObj *obj = [m_doc advanceGetObj:[page advanceGetRef]];

    int count = [obj dictGetItemCount];    

    for (int cur = 0; cur < count; cur++) {
        NSString *tag = [obj dictGetItemTag:cur];
        PDFObj *item = [obj dictGetItemByIndex:cur];
        int type = [item getType];
        if ([tag isEqualToString:@"MediaBox"] || [tag isEqualToString:@"CropBox"])
        {
            int arr_count = [item arrayGetItemCount];
            PDFObj *boxWidth = [item arrayGetItem:2];
            PDFObj *boxHeight = [item arrayGetItem:3];
            [boxWidth setIntVal:width];
            [boxHeight setIntVal:height];
        }
    }
    [m_doc save];
}

Loading ...