Getting Y co-ordinate of a page in mpdf - pdf-generation

I am using mpdf to generate certain tables on a pdf. Each table has a title text on top of it. I want to know the current y coordinate of the page to make the output proper. Currently sometimes the title comes on 1 page and the table on the next
I tried using $mpdf->GetY()
but it gives an error. Please help

Hi i got the solution to my question..used $mpdf->y which returned my y position. So i could check if the y position is greater than the approx height of the table. :)

class mPDF has a public property $y
You can directly get Y co-ordinate by accessing this variable.
Check if that works for you.

Related

Dynamix Xpath for bounds in appium

I want to create a dynamic xpath in appium to get the elements using bounds that has x coordinates 53 and varying y coordinates. This code is giving me error "Could not find function:"
driver.findElements(By.xpath("[(contains(#bounds, '][53,'))]"));
Try using below code it works for me on android
driver.findElement(By.xpath("//android.widget.ImageButton[#bounds='[9,288][144,318]']"));
I managed to get the partial match working.
I'm not sure but perhaps your issue is that you are using "][53," which matches the bottom right corner x position. The code I tested with used the top left corner x and y position.
close_button = driver.find_element(by=AppiumBy.XPATH, value="//android.widget.ImageButton[contains(#bounds, '[78,78][') and #clickable='true']")
Your question actually was the answer I was looking for.

itext correctly get each image position within page or document

Experimenting with itext I am extracting both text and images from pdf files. For my purpose I build an html file using the text and images. The goal is to place the extracted images throughout the text rather than placing them at the end as I do currently.
After some research itext renderInfo.getImageCTM() appears to be just what I need, however the coordinates returned do not resemble the positions of some of the images when comparing to what's being displayed in adobe reader.
My MyImageRenderListener class has this
Matrix matrix = renderInfo.getImageCTM();
float x = matrix.get(Matrix.I31);
float y = matrix.get(Matrix.I32);
Which should give me the XY, top left hand corner position of each image, if I've understood it correctly.
Here is the pdf file I will be referring to
It's a 4 page PDF that contains either one or two images per page.
PAGE X Y
Page1 33.0 358.5
Page2 1st 321.7 419.9
Page2 2nd 41.2 182
Page3 1st 43.1 307.5
Page3 2nd 417 58.5
Page4 292.5 457.5
When comparing the coordinates output to the actual document the numbers do not seem to make sense. For example, On page3, the second image Y (58.5) is lower than the first image Y (307.5) on the same page. That would put image 2 on page 3 before image 1??
Also none of the Y and some of the X coordinates appear to be correct when comparing to the layout in any reader.
What am I getting wrong or miss understanding please?

SSRS Lable Printing

I have a SSRS RDL that is formated to fit on a three column lable sheet. When exported to PDF the 2nd column is not populated and on the next page the 2nd column is the only column populated. This continues to happen for as much data as I have. Has anyone had any problems with this or might have an idea on where the problem might be?
These kinds of quirks are usually related to the margins. Make sure that the actual label area does not exceed the page size, accounting for the margins. Also, printer drivers can cause a similar issue because of content-to-page-size issues, where the report shows correct on-screen but when printing, shifts content to a new page.
This is because of page setup properties. For example if a page is set to letter size(8.5in X 11in) and left and right margins to 1 inch. then you have adjust you report body size to 6.5 inch or below, if it exceeds above 6.5 inch, then leads to split data to other pages when exported to PDF.

Manipulating subsections of an array

I am using R to plot trying to conditionally change parts of an array
based on the columns of the array.
I have worked out the following steps:
x<-array(1,dim=c(4,4,3))
r<-x[,,1]
g<-x[,,2]
b<-x[,,3]
r1<-apply(r[,2:3],1:2,function(f){return(0)})
g1<-apply(g[,2:3],1:2,function(f){return(0)})
b1<-apply(b[,2:3],1:2,function(f){return(0)})
r3<-cbind(r[,1],r1,r[,4])
g3<-cbind(g[,1],g1,g[,4])
b3<-cbind(b[,1],b1,b[,4])
# Pass to pixmapRGB
This works, but as I am new to R, I was wondering if
there was a more efficient way to manipulate parts
of an array.
For example, does apply know which element it is working on?
The bigger picture is that I want to graph a time-series scatter
plot over many pages.
I would like to have a thumbnail in the corner of the page that is
a graph of the whole series. I would like to color a portion of
that thumbnail a different color to indicate what range the
current page is examining.
There is alot of data, so it is not feasible to redraw a new plot
for the thumbnail on every page.
What I have done is to first write the thumbnail plot out to a tiff file.
Then I read the tiff file back in, used getChannels from pixmap
to break the picture into arrays, and used the above code to change
some of the pixels based on column.
Finally I then print the image to a viewport using
pixmapRGB/pixmapGrob/grid.draw
It seems like alot of steps. I would be grateful for any pointers
that would help me make this more efficient.
Maybe I don't understand your question, but if what you're trying to do is just "change some pixels based on column," why don't you just use the basic array indexing to do that?
This will do the same thing you have posted:
x<-array(1,dim=c(4,4,3))
r<-x[,,1]
g<-x[,,2]
b<-x[,,3]
r[,2:3]=0
g[,2:3]=0
b[,2:3]=0
Is that helpful?
Perhaps more of a comment than an answer, but when I try to plot over a number of pages I usually go left to right, breaking up the plots into quantiles and setting appropriate xlim (or ylim)
x <- rnorm(100000)
y <- rnorm(100000)
df <- data.frame(x,y)
seq1 <- quantile(df$x, probs = seq(0,1,0.1))
seq2 <- quantile(df$x, probs = seq(0,1,0.1))
for(x in 1:(length(seq1)-1)) {
plot(df, xlim=c(seq1[x],seq1[x+1]))
}
No idea how to overlay a thumbnail onto the graphs although I think you could do this with one of the rimage functions if you saved the thumbnail.
You could avoid having to read and paste a tiff thumbnail by actually replotting the whole chart at reduced scale. check out par(fig) , and then do something like
Rgames: plot(1:2,1:2)
Rgames: par(mar=c(.1,6,.1,.1),new=T,fig=c(0,.25,.5,.75))
Rgames: plot(1:2,1:2)
Rgames: polygon(c(1,2,2,1),c(1,1,2,2),col='red')
("Rgames:" is my prompt)
You'll have to play a bit with the margin values, but this will get your "mini-graph" set up.

OpenGL text position under Windows

I am developing an OpenGL application that has two working modes: windowed mode and full screen.
The app displays several graphic objects using OpenGL and writes some text strings using that same API. The program displays the texts strings in its intended positions when running as a windowed application, but when running full screen the text strings are displayed in an upper position that its intended position.
The app creates the fonts using wglUseFontBitmap and displays the text strings with glCallLists (it sets the text position using glRasterPos2i). Before the text is displayed I adjust the text position adding an offset to the Y coord. I get that offset using the GetDCOrgEx Win32 API call.
I think you have to call GetDCOrgEx again after getting in fullscreen mode, or do you already do this? It would help if you could post the code where you call GetDCOrgEx and calculate the Y offset.
EDIT: Another idea: Could it be that you can use the same Y offset, but negative? Or perhaps calculate Y position and then use height-ypos? There's some source code here that uses glRasterPos2i different when in fullScreen:
if(!state->fullScreen)
// if fullScreen (don't forget the image/GL y-coord vertical flip)
glRasterPos2i((w - state->img->cols())/2, (h - state->img->rows())/2);
else
// for non-fullscreen images
glRasterPos2i(0,h);
Schnaader, thanks a lot for your answers.
I have solved the problem modifying how I calculate the offset that I need to add to the Y coord. Now the offset is calculated with the following code:
m_iYOffset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER);
The above code solves the problem for my application.
Here's the code to calculate the Y offset:
POINT vOffset;
m_hdc = GetDC(m_hWnd);
if (m_hdc)
{
GetDCOrgEx(m_hdc, &vOffset);
m_iYOffset = vOffset.y;
}
The above code is called once the program has set up full screen mode. I tried to call GetDCOrgEx every time I need to write a text string, but the text is written at the same positions that when GetDCOrgEx is called only once.

Resources