Method: FPDF#AddPage

Defined in:
lib/fpdf.rb

#AddPage(orientation = '') ⇒ Object



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/fpdf.rb', line 277

def AddPage(orientation='')
    # Start a new page
    self.Open if @state==0
    family=@FontFamily
    style=@FontStyle+(@underline ? 'U' : '')
    size=@FontSizePt
    lw=@LineWidth
    dc=@DrawColor
    fc=@FillColor
    tc=@TextColor
    cf=@ColorFlag
    if @page>0
        # Page footer
        @InFooter=true
        self.Footer
        @InFooter=false
        # Close page
        endpage
    end
    # Start new page
    beginpage(orientation)
    # Set line cap style to square
    out('2 J')
    # Set line width
    @LineWidth=lw
    out(sprintf('%.2f w',lw*@k))
    # Set font
    SetFont(family,style,size) if family
    # Set colors
    @DrawColor=dc
    out(dc) if dc!='0 G'
    @FillColor=fc
    out(fc) if fc!='0 g'
    @TextColor=tc
    @ColorFlag=cf
    # Page header
    self.Header
    # Restore line width
    if @LineWidth!=lw
        @LineWidth=lw
        out(sprintf('%.2f w',lw*@k))
    end
    # Restore font
    self.SetFont(family,style,size) if family
    # Restore colors
    if @DrawColor!=dc
        @DrawColor=dc
        out(dc)
    end
    if @FillColor!=fc
        @FillColor=fc
        out(fc)
    end
    @TextColor=tc
    @ColorFlag=cf
end