In pdf_set_Orientation, the pdf stream name is
hard-coded to "Spdf"
The lines:
L_width = pdf_PageWidth("Spdf").
L_height = pdf_PageHeight("Spdf").
Should be:
L_width = pdf_PageWidth(pdfStream).
L_height = pdf_PageHeight(pdfStream).