pdf generation - PdfDocument detect page height android -


using loops m generating content pdf document page , increment downwards using

baseline = baseline + linespacing;  

for (x,y) positions

problem : m unable find when should loop break? use

if (baseline > pageheight) {break;} 

and start new page writes beyond pageheight (how know? because see cutoff text @ end of page) (i m not using itext)

is there better solution ending page?

maintain variable private float currenttopy; save current position of page

private static final float left_margin = 10f; private static final float page_height = 792f; private static final float page_width = 595f; private static final float top_bottom_margin = 5f;  private void createpdfpage() throws ioexception {     page = new pdpage();     document.addpage(page);     currenttopy = page_height - top_bottom_margin;     currentpagenumber = currentpagenumber + 1; }  private void addnewline(int numberoflines) {     currenttopy = currenttopy - (numberoflines * new_line); } 

and everytime before adding pdfdocument make following check:

if (currenttopy - top_bottom_margin < height) {         createpdfpage(); }  currenttopy = currenttopy - height; 

where height height of component(like image etc.) adding document.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -