PDF Report Generator - Landscape not working - CW11

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?

LocalWMFParser                            WMFDocumentParser             
PDFReporter                               CLASS(PDFReportGenerator)     
SetUp                                       PROCEDURE(),DERIVED
                                          END

PDFReporter.SetUp()
PDFReporter.SetFileName(wrkFileNamePDF)
PDFReporter.SetDocumentInfo('CW Report','Version','PdfReport','PdfReport','Coyright','keywords')
PDFReporter.SetPagesAsParentBookmark(False)
PDFReporter.CompressText    = True
PDFReporter.CompressImages  = True
PDFReporter.SetScanCopyMode(True)
PDFReporter.SetScanCopyResolution(PNGImageResolution:Original)

IF Self.Report{PROP:Landscape}
   PDFReporter.SetPageLandscape()
ELSE
   PDFReporter.SetPagePortrait ()
END
PDFReporter.SetPageType(PAPER:USER) 

LocalWMFParser.Init(PreviewQueue, PDFReporter.IReportGenerator)

RC#  = LocalWMFParser.GenerateReport()

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.

Did you confirm that the report looks correct when you print it to a printer?

Why not PAPER:Letter ?

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.

Where is the code for your report coming from?

Similar to what @CarlBarnes is asking…

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?