Skip to main content
Participating Frequently
February 15, 2021
Answered

How to print horizonal by using a java script ?

  • February 15, 2021
  • 1 reply
  • 1795 views

Hello together,

I need to print my PDF Document via JavaScript. 

These are my printParams which I use and which works very well:

              pp.interactive = pp.constants.interactionLevel.silent;
              pp.firstPage = 0;
              pp.lastPage = 0;
              pp.pageHandling = pp.constants.handling.fit;
              pp.nUpAutoRotate = true;

Is there any possible Java Code which makes it possible to rotate my print page from vertical to horizonal? 

I tried everything could you please help me?

Best regards

This topic has been closed for replies.
Correct answer try67

In the picture bellow you can see

-my test page

-exact code

-message after executing the code (yellow marked) no error

Thanks!!


OK, pretty much everything there is wrong.

Use this code:

 

this.setPageRotations(0,0,90);

this.print({
	bUI:true,
	nStart:0,
	nEnd:0,
	bShrinkToFit:true
});

1 reply

ls_rbls
Braniac
February 18, 2021

See the setPageRotations parameter explained below:

 

nRotate (optional) The amount of rotation that should be applied to the target pages. Can be 0, 90, 180, or 270. The default is 0. Example Rotate pages 0 through 10 of the current document.

 

this.setPageRotations(0, 10, 90); 

 

You can read more about it in the Adobe Acrobat SDK JavaScript API JavaScript for Acrobat API Reference, setPageTabOrder, page 342

Participating Frequently
February 23, 2021

Hello,

thanks for yout idea. I tried your code and different variations of it but it doesnt work. I will show you what I have done. I run the following script:

this.print({
bUI:true,
nStart:0,
nEnd:0,
bShrinkToFit:true
setPageRotations:(0,10,90)
})

but the print option(look at my screenshot) does not switch to horizontal (yellow marked area). I need to turn ON the yellow marked option by javascript.

Thankyou and Best regards

try67
Braniac
February 23, 2021

setPageRotations has nothing to do with the print command. It's its own command to rotate the pages.

You should use the code provided by ls_rbls, before calling the print command (and after, if you want to rotate the pages back to their original views).