Robert Valentino Well-Known Member Licensed User Longtime User Feb 27, 2019 #1 B4X: Private mPDF As PdfDocument mPDF.Initialize mPDF.StartPage(mPageSize.Width, mPageSize.Height) TextHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString, mFont_Roboto_Regular, (10 / mScale)) SubHeadingHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString, mFont_Roboto_Regular, (14 / mScale)) PdfDocument requires that you do a StartPage before you can MeasureStringHeight or MeasureStringWidth Normally I measure my Header items to determine where I want to place them on the page (ONLY Done once) before actually doing the pages Having to do a StartPage before measuring items I find throws off the whole Next Page logic. I am converting from PDFWriter which asks for the page size when you do the Initialize ALSO: Would be nice if we had a mPDF.IsInitialized function and maybe mPDF.IsPageStarted BobVal
B4X: Private mPDF As PdfDocument mPDF.Initialize mPDF.StartPage(mPageSize.Width, mPageSize.Height) TextHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString, mFont_Roboto_Regular, (10 / mScale)) SubHeadingHeight = mPDF.Canvas.MeasureStringHeight(mMeasureHeightString, mFont_Roboto_Regular, (14 / mScale)) PdfDocument requires that you do a StartPage before you can MeasureStringHeight or MeasureStringWidth Normally I measure my Header items to determine where I want to place them on the page (ONLY Done once) before actually doing the pages Having to do a StartPage before measuring items I find throws off the whole Next Page logic. I am converting from PDFWriter which asks for the page size when you do the Initialize ALSO: Would be nice if we had a mPDF.IsInitialized function and maybe mPDF.IsPageStarted BobVal
Erel B4X founder Staff member Licensed User Longtime User Feb 28, 2019 #2 Use a different canvas for the measurement. You can create a 1 x 1 mutable bitmap and create a canvas with Initialize2.
Use a different canvas for the measurement. You can create a 1 x 1 mutable bitmap and create a canvas with Initialize2.