Trying to add PDF output to a small hand coded project.
Portrait works fine, but if the report is landscape each page is cutoff like it is shifted up 50% with rest of page blank.
Any ideas?
Yep. I had a similar problem. A portrait report was printed landscape on portrait paper (or pdf).
in my case the solution, as pointed out by Lee, was there was no printer defined. As a result the context of the monitor was used to create the WMFs and the monitor was ONLY landscape.
So my answer would be to look at the default printer, if any.
If none, you need to add one.
I know what you’re talking about but I don’t think this is that issue. The report is absolutely the right size. It’s just shifted up by 50% and truncated and the bottom half of the page is blank. I do have a default printer and everything works fine for portrait. I just can’t figure out why it doesn’t work for landscape. When I use the reports example app landscape works fine. I just can’t figure out what’s wrong with my hand code and what setting I’m forgetting to do so it works correctly. thank you for your thoughts.
I think PAPER:USER needs Width and Length, say from Report PropPrint:PaperWidth and Height. Is there a need to deal with Units, i.e. Reports in 1/1000" versus PDF in Points? I think not.
When do you set Landscape is a question. I would think you set Paper to Letter First, then set Landscape and it flips Width and Height.
You have all the source in ABPrPdf.Inc/Clw to answer some of these questions e.g. see below Paper:User sets page to Letter if no Width/Height passed:
PDFGeneratorClass.SetPageType PROCEDURE(SHORT pPageType,LONG pWidth=0,LONG pHeight=0) ! The size is in 1/1000 inch
CODE
SELF.PageType = pPageType
IF pPageType=PAPER:USER THEN
IF pWidth=0 OR pHeight=0
SELF.PageType = PAPER:LETTER
SELF.SetPageSize()
ELSE
SELF.SetPageSize(pWidth/(8500/612),pHeight/(8500/612))
END
ELSE
SELF.SetPageSize()
END
Set SetPageLandscape() just sets a property, later at output it flips Width/Height
PDFGeneratorClass.SetPageLandscape PROCEDURE()
CODE
SELF.PageLandscape = True
...
PDFGeneratorClass.CloseDocument PROCEDURE()
and
PDFGeneratorClass.EndPage PROCEDURE()
...
IF SELF.PageLandscape = False THEN
SELF.Output.WriteLine('/MediaBox [ 0 0 '&SELF.PageWidth&' '&SELF.PageHeight&' ]')
ELSE
SELF.Output.WriteLine('/MediaBox [ 0 0 '&SELF.PageHeight&' '&SELF.PageWidth&' ]')
END
Using the LibSrc Code you should be able to figure out what;s wrong, also looking in the PDF file.
Is the report you are trying to print already defined as Landscape, or Portrait? If it is already designed as Landscape, why are you re-specifying the report orientation?