Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  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
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  Location: Dortmund
|
Hi Everybody! Are there any suggestions? Hope for a hint! Oliwan
|
|
|
|
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
|
|
|
|
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
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  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
|
|
|
|
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();
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  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
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 936
Thanks: 3 times Was thanked: 112 time(s) in 109 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  Location: Dortmund
|
Hey Paul!
Thank's a lot - now it's clear fo me!
Oliwan
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  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
|
|
|
|
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  p.s.i can provide images if you need It will be helpful as well as PDF file.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 11/23/2017(UTC) Posts: 7  Location: Dortmund
|
I just sent you some downloadliks via mail! Oliwan
|
|
|
|
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
|
|
|
|
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=csharpgeneralCode:
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
}
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 936
Thanks: 3 times Was thanked: 112 time(s) in 109 post(s)
|
|
|
|
|
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close