logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages<12
Options
Go to last post Go to first unread
Oliwan  
#21 Posted : Thursday, November 23, 2017 5:13:20 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Hi everybody!

I'm new in interacting with pdfium - the reasen why i've started with it, is that
i want to be able to print Postscript or PDF files onto any kind of printer.

Based on the code snippets which are available i've reached this code:

Code:
            PdfCommon.Initialize();
            PdfDocument doc = PdfDocument.Load("C:\\test.pdf");
            PrinterSettings prnsettings = new PrinterSettings {
                PrinterName = @"MyPrinterName",
                PrintRange = PrintRange.AllPages
            };

            System.Drawing.Printing.Margins margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            prnsettings.DefaultPageSettings.Margins = margins;

            PdfPrintDocument printDoc = new PdfPrintDocument(doc);
            printDoc.PrinterSettings = prnsettings;
            
            PrintController printController = new StandardPrintController();
            printDoc.PrintController = printController;
            printDoc.Print();


When i comment out the Printersettings line (printDoc.PrinterSettings=prnsettings;) the files got's be printed
but when i try to make some printer settings - nothings happens on printer side.

So here are some questions which are spinning around in my head:
Is it correct to combine System.Drawing.Prinnting Settings with pdfium?
How can i select the target printer correctly with pdfium?
I want to prohibide, that the pdf got's be scaled down (fit to page) by the printer- how can i make
such a setting with pdfium?
I want to configure a specific Paper try - i.e. 2 instead of 1 - how can i make such a setting
with pdfium?

Thanks a lot so far
Oliwan
may the source be with you

Edited by moderator Sunday, October 6, 2019 8:06:28 PM(UTC)  | Reason: Not specified

Oliwan  
#22 Posted : Wednesday, November 29, 2017 10:22:32 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Hi Everybody! Are there any suggestions?
Hope for a hint!
Oliwan
PataAndrey  
#23 Posted : Thursday, November 30, 2017 7:22:39 AM(UTC)
PataAndrey

Rank: Member

Groups: Registered
Joined: 11/3/2017(UTC)
Posts: 7

Was thanked: 1 time(s) in 1 post(s)
Hi Oliwan! Sorry for the late reply.

Our developers will check this.

Edited by moderator Thursday, November 30, 2017 7:27:01 AM(UTC)  | Reason: Not specified

Paul Rayman  
#24 Posted : Thursday, November 30, 2017 7:30:07 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Hi,

You also should specify the MinimumPage property.
Like shown below

Code:

PrinterSettings prnsettings = new PrinterSettings
{
	PrinterName = @"MyPrinter",
	PrintRange = PrintRange.AllPages,
	MinimumPage = 1
};


By the way, the settings may be initialized via standard .net print dialog window like shown earlier in this topic.

Edited by user Thursday, November 30, 2017 7:32:20 AM(UTC)  | Reason: Not specified

Oliwan  
#25 Posted : Friday, December 1, 2017 6:47:29 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Thanks Paul!

I changed my code - but the result is the same - nothing happens on printer side, when i
use the printersettings like you mentioned.

Perhaps i have to add any further using reference in my code to be able to use printer settings?

Here you get a better view of what i've done so far including my using references:

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Patagames.Pdf;
using Patagames.Pdf.Net;
using Patagames.Pdf.Net.Controls.Wpf;
using System.Drawing.Printing;
using System.Diagnostics;

namespace PDFiumPrintGambling
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            
            PdfCommon.Initialize();
            PdfDocument doc = PdfDocument.Load("C:\\test.pdf");
            PrinterSettings prnsettings = new PrinterSettings {
                PrinterName = @"\\DH-DRUCKSERVER\drucker002",
                PrintRange = PrintRange.AllPages,
                MinimumPage = 1
            };

            System.Drawing.Printing.Margins margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            prnsettings.DefaultPageSettings.Margins = margins;

            PdfPrintDocument printDoc = new PdfPrintDocument(doc);
            printDoc.PrinterSettings = prnsettings;
            
            PrintController printController = new StandardPrintController();
            printDoc.PrintController = printController;
            printDoc.Print();

          
        }




Thanks your help in advance
Oliwan

Edited by moderator Sunday, October 6, 2019 8:06:49 PM(UTC)  | Reason: Not specified

Paul Rayman  
#26 Posted : Friday, December 1, 2017 7:18:27 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Well, of course!

You should not create a new instance of PrinterSettings.
The printer properties dos not initialize properly in this case.
Instead of that you should get the PrinterSettings object through PrintDocument.

Please look at code below

Code:

PdfPrintDocument printDoc = new PdfPrintDocument(doc);
printDoc.PrinterSettings.PrinterName = @"Canon G3000 series Printer";

PrintController printController = new StandardPrintController();
printDoc.PrintController = printController;
printDoc.Print();
Oliwan  
#27 Posted : Monday, December 4, 2017 2:59:44 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Hello Paul,

thanks for the hint!
Can you provide me with informations regarding using the diffent
printersettings Parameter?

How do i have to set the scaling on/off or to explicit value?

At the moment, any print out got's scaled like "Fit to page" what i don't want to be happen.

Further more, should it be possible to set a specific PaperSource, to set s specific resolution?

Thanks again for your patience!!!

May the source be with you

Oliwan
Paul Rayman  
#28 Posted : Monday, December 4, 2017 3:19:35 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Quote:
How do i have to set the scaling on/off or to explicit value?

At the moment, any print out got's scaled like "Fit to page" what i don't want to be happen.


PdfPrintDocument.PrintSizeMode
https://pdfium.patagames...35-7791-baede0ca910b.htm

+

PdfPrintDocument.Scale
https://pdfium.patagames...63-78a9-1c3c67962584.htm

Quote:
Further more, should it be possible to set a specific PaperSource, to set s specific resolution?


Such features features are not PDF specific and should be accessible through standard PrintDocument (base class for PdfPrintDocument class)
You can found more info here
https://social.msdn.micr...ment?forum=csharpgeneral

Edited by user Monday, December 4, 2017 3:31:26 AM(UTC)  | Reason: Not specified

Oliwan  
#29 Posted : Monday, December 4, 2017 8:54:41 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Hey Paul!

Thank's a lot - now it's clear fo me!

Oliwan
Oliwan  
#30 Posted : Monday, December 4, 2017 10:18:02 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

Dear Paul,

the most needed settings are now under control - i can set the printer, the paper source
and the paper size settings and resolution - wonderful!

But there is still one point which is not fullfilling our expectations ;-(

When i print my sample pdf via Acrobat reader (what of course could be done via c# code)
i got a well looking print result (Base PDF is 600 dpi containing multiple dots - like you perhapsly
known form livescribe?!) - the dots are well positioned and printed - and also the forms layout (images / text aso)

When i print my sample pdf via pdfium the print be not comparable with the acrobat quality
1) the position of the content is moved 4 mm to the left and to the bottom (upper left corner)
2) the dot pattern became ugle fragmented

The main problem is the fragmented dot pattern - it is unusable when i print it with pdfium ;-(
-> when i examin the print result of pdfium i recognize, that the "black" dots are printed colored
(not all but some of them)
I dont't now why, but the print result seemes to be colorized by its way through pdfium?!
Do you have any idea how i can prevent this colorizing?

Thanks

Oliwan

p.s.i can provide images if you need

Edited by user Tuesday, December 5, 2017 3:43:45 AM(UTC)  | Reason: Not specified

Paul Rayman  
#31 Posted : Tuesday, December 5, 2017 3:51:55 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Originally Posted by: Oliwan Go to Quoted Post
p.s.i can provide images if you need


It will be helpful as well as PDF file.
Oliwan  
#32 Posted : Tuesday, December 5, 2017 5:58:39 AM(UTC)
Oliwan

Rank: Newbie

Groups: Registered
Joined: 11/23/2017(UTC)
Posts: 7
Germany
Location: Dortmund

I just sent you some downloadliks via mail!
Oliwan
Guest  
#33 Posted : Thursday, January 11, 2018 2:16:13 PM(UTC)
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 153

Was thanked: 4 time(s) in 4 post(s)
Is there a way to change the paper trays from the PdfDocument or PdfPrintDocument objects? The PdfPrintDocument has a PaperSources parameter but it is Read-Only so how do you set which trays to print from?

EDIT: I did find a way to set the DefaultPageSettings PaperSource.

Edited by user Thursday, January 11, 2018 3:30:42 PM(UTC)  | Reason: Not specified

Paul Rayman  
#34 Posted : Thursday, January 11, 2018 7:02:20 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Hi,

Because PdfPrintDocument derived from the .Net PrintDocument you may use the following
https://social.msdn.micr...ment?forum=csharpgeneral

Code:


 using (PrintDocument printDoc = new PrintDocument())
 { 
      printDoc.PrinterSettings.PrinterName = "PrinterName";
      //Replace "PrinterName" with the printer name
      printDoc.DefaultPageSettings.PaperSource =      printDoc.PrinterSettings.PaperSources[0];
      // replace 0 with the index
      //your code 
}

Paul Rayman  
#35 Posted : Monday, January 22, 2018 12:16:56 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 936

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Users browsing this topic
2 Pages<12
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.