How can i create landscape PDF using android native PdfDocument API? -


i using pdfdocument api write pdf view using android

problem

if writing pdf of a4 size. how can make in landscape mode?

thanks in advance.

a typical use of android pdf apis looks this:

// create new document pdfdocument document = new pdfdocument();  // crate page description pageinfo pageinfo = new pageinfo.builder(300, 300, 1).create();  // start page page page = document.startpage(pageinfo);  // draw on page view content = getcontentview(); content.draw(page.getcanvas());  // finish page document.finishpage(page); . . . // add more pages . . . // write document content document.writeto(getoutputstream());  // close document document.close(); 

according developer.android.com reference:

public pdfdocument.pageinfo.builder (int pagewidth, int pageheight, int pagenumber) 

added in api level 19

creates new builder mandatory page info attributes.

parameters

pagewidth page width in postscript (1/72th of inch).

pageheight page height in postscript (1/72th of inch).

pagenumber page number.

to create pdf portrait a4 pages, therefore, can define page descriptions this:

pageinfo pageinfo = new pageinfo.builder(595, 842, 1).create(); 

and pdf landscape a4 pages, can define them this:

pageinfo pageinfo = new pageinfo.builder(842, 595, 1).create(); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -