PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Dec 10, 2018 9:37 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Thu Sep 27, 2018 12:01 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2018 2:31 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2018 2:35 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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....


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2018 3:25 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2018 3:31 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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...


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 6:47 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 11:14 am 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 2:43 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 01, 2018 7:10 am 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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!


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 01, 2018 2:53 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 02, 2018 1:19 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
Any hint about how to close the adobe afeter the execution of my comands??


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 02, 2018 3:33 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 02, 2018 3:37 pm 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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();


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 02, 2018 9:31 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 03, 2018 7:16 am 
Offline

Joined: Thu Sep 27, 2018 11:55 am
Posts: 9
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group