PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

How to rotate an existing PDF?
http://forum.pdfsharp.com/viewtopic.php?f=2&t=3851
Page 1 of 1

Author:  AitorEG [ Thu Sep 27, 2018 12:01 pm ]
Post subject:  How to rotate an existing PDF?

Hi everyone,

I've just started using PDFSharp library, for fixing an issue I found in Dynamics NAV. I'm loading a PDF file from an known directory, and sending it to a printer, with this code:

Code:
  Printer := Printer.PdfFilePrinter(FileNameServer);
  Printer.DefaultPrinterName := 'Etiquetas Expediciones 2';
  Printer.AdobeReaderPath('C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe');
  Printer.Print();


Print is a "PdfSharp.Pdf.Printing.PdfFilePrinter" variable. But now, I need to rotate to landscape mode the file, before sending it to the printer. I've read something about the xgraphics objets, rotateTransform... But I'm quite lost with all this. Any hint on how can I fix this problem?
Of course my idea is to "load" the PDF file from the dierctory, that could be more than 1 page, rotate it, and save it again, and after that, prinit it as I'm doing already

Thank you all

Author:  Thomas Hoevel [ Thu Sep 27, 2018 2:31 pm ]
Post subject:  Re: How to rotate an existing PDF?

Hi!
AitorEG wrote:
Any hint on how can I fix this problem?
I'm afraid I don't understand the problem.
I assume Adobe Reader will rotate the pages automatically while printing, so rotating the page before printing may not make any difference.

The PdfFilePrinter is just an interface to the commandline options of Adobe Reader and it cannot solve all problems.

Author:  AitorEG [ Thu Sep 27, 2018 2:35 pm ]
Post subject:  Re: How to rotate an existing PDF?

Thomas Hoevel wrote:
Hi!
AitorEG wrote:
Any hint on how can I fix this problem?
I'm afraid I don't understand the problem.
I assume Adobe Reader will rotate the pages automatically while printing, so rotating the page before printing may not make any difference.

The PdfFilePrinter is just an interface to the commandline options of Adobe Reader and it cannot solve all problems.


Thanks for your answer Thomas. The thing is that, I'm sending the PDF directly to NAV, without openning it on the adobe. So, the PDFFileprinter should receive the file rotated...

Hope I've explained myself correctly....

Author:  Thomas Hoevel [ Thu Sep 27, 2018 3:25 pm ]
Post subject:  Re: How to rotate an existing PDF?

AitorEG wrote:
The thing is that, I'm sending the PDF directly to NAV, without openning it on the adobe. So, the PDFFileprinter should receive the file rotated...
PdfFilePrinter just invokes Adobe Reader with some commandline options.
And I assume Adobe Reader will handle portrait/landscape automatically by default.

When using PdfFilePrinter you are actually using Adobe Reader. Try rotation, but don't be surprised if it makes no difference.

Author:  AitorEG [ Thu Sep 27, 2018 3:31 pm ]
Post subject:  Re: How to rotate an existing PDF?

Thomas Hoevel wrote:
AitorEG wrote:
The thing is that, I'm sending the PDF directly to NAV, without openning it on the adobe. So, the PDFFileprinter should receive the file rotated...
PdfFilePrinter just invokes Adobe Reader with some commandline options.
And I assume Adobe Reader will handle portrait/landscape automatically by default.

When using PdfFilePrinter you are actually using Adobe Reader. Try rotation, but don't be surprised if it makes no difference.



Thanks Thomas,

I understand that, that is way I need to rotate all the PDF before sending to the printer. Tha pages of the PDF are 150mmx150mm, square, so doesnt mind if it's landscape or portrait. Just need to rotate 90ยบ becasue of the printer orientation...

Author:  TH-Soft [ Fri Sep 28, 2018 6:47 am ]
Post subject:  Re: How to rotate an existing PDF?

Hi!
AitorEG wrote:
Any hint on how can I fix this problem?
Every page has a "/Rotate" property that allows multiples of 90 degrees (e.g. 0, 90, 180, 270).
Open the PDF for modification, for every page increase this value by 90, save the file, and you should be done.

Author:  AitorEG [ Fri Sep 28, 2018 11:14 am ]
Post subject:  Re: How to rotate an existing PDF?

TH-Soft wrote:
Hi!
AitorEG wrote:
Any hint on how can I fix this problem?
Every page has a "/Rotate" property that allows multiples of 90 degrees (e.g. 0, 90, 180, 270).
Open the PDF for modification, for every page increase this value by 90, save the file, and you should be done.


Thanks Thomas,
I've found this psot, and I'm trying to understand how it's working:

viewtopic.php?f=2&t=1882

What I've understood, is that I need to load the file into a form. After that, I should create pages, and rotate every one of them?
Sorry, but it's a little hard for me to understand what it's doing that piece of code, and translate it into C/AL code...

Really appreciate your answers

Author:  TH-Soft [ Fri Sep 28, 2018 2:43 pm ]
Post subject:  Re: How to rotate an existing PDF?

AitorEG wrote:
What I've understood, is that I need to load the file into a form. After that, I should create pages, and rotate every one of them?
You can try that.
I'd open the file for modification and for each page do something like
Code:
page.Rotate += 90;

Then save the file and check it with Adobe Reader or other viewers.

Author:  AitorEG [ Mon Oct 01, 2018 7:10 am ]
Post subject:  Re: How to rotate an existing PDF?

TH-Soft wrote:
AitorEG wrote:
What I've understood, is that I need to load the file into a form. After that, I should create pages, and rotate every one of them?
You can try that.
I'd open the file for modification and for each page do something like
Code:
page.Rotate += 90;

Then save the file and check it with Adobe Reader or other viewers.


THnak you, really appreciate your tip. I'll work on it!

Author:  AitorEG [ Mon Oct 01, 2018 2:53 pm ]
Post subject:  Re: How to rotate an existing PDF?

TH-Soft wrote:
AitorEG wrote:
What I've understood, is that I need to load the file into a form. After that, I should create pages, and rotate every one of them?
You can try that.
I'd open the file for modification and for each page do something like
Code:
page.Rotate += 90;

Then save the file and check it with Adobe Reader or other viewers.


Thanks for your tip Thomas. Finally, the service provider ahs changed the size of the PDF, so I dont need to rotate it. But now I'0m finding one small issue... The Adobe reader stills open after the execution. How can I close it??
Thank you again

Author:  AitorEG [ Tue Oct 02, 2018 1:19 pm ]
Post subject:  Re: How to rotate an existing PDF?

Any hint about how to close the adobe afeter the execution of my comands??

Author:  TH-Soft [ Tue Oct 02, 2018 3:33 pm ]
Post subject:  Re: How to rotate an existing PDF?

AitorEG wrote:
Any hint about how to close the adobe afeter the execution of my comands??
"Kill()" the "Process".
Maybe kill it only if there was no Adobe Reader process before printing.

Author:  AitorEG [ Tue Oct 02, 2018 3:37 pm ]
Post subject:  Re: How to rotate an existing PDF?

TH-Soft wrote:
AitorEG wrote:
Any hint about how to close the adobe afeter the execution of my comands??
"Kill()" the "Process".
Maybe kill it only if there was no Adobe Reader process before printing.


I don't think that is possible in Dynamics NAV.... I think I should use some function against "printer"

Code:
 
  Printer := Printer.PdfFilePrinter(FileNameServer);
  Printer.DefaultPrinterName := 'Etiquetas Expediciones 2';
  Printer.AdobeReaderPath('C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe');
  Printer.Print();

Author:  TH-Soft [ Tue Oct 02, 2018 9:31 pm ]
Post subject:  Re: How to rotate an existing PDF?

AitorEG wrote:
I don't think that is possible in Dynamics NAV.... I think I should use some function against "printer"
When it is possible to start Adobe Reader using the PdfFilePrinter class, then you can also kill that process again, I assume.

Maybe this helps:
https://stackoverflow.com/a/6465215/1015447

Author:  AitorEG [ Wed Oct 03, 2018 7:16 am ]
Post subject:  Re: How to rotate an existing PDF?

TH-Soft wrote:
AitorEG wrote:
I don't think that is possible in Dynamics NAV.... I think I should use some function against "printer"
When it is possible to start Adobe Reader using the PdfFilePrinter class, then you can also kill that process again, I assume.

Maybe this helps:
https://stackoverflow.com/a/6465215/1015447


I've tried to use

Quote:
printer.Print(1000);


but nothing, seems to be an issue with the system architecture of the navision, a client-server issue

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/