PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 1:04 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Aug 27, 2012 8:32 am 
Offline

Joined: Mon Aug 27, 2012 8:23 am
Posts: 3
Hello,

I am new to MigraDoc & PDFSharp but it is very simple to use. Creating documents is really easy.

Today I have tried to print a generated document and I always get an error message while using DocumentFromFile:

My System is in German and says:

"Symbol '\\document' erwartet, '%' vorgefunden."
In English it should be something like "Symbol '\\document' expected, '%' found".

I also have tried to open regular PDF that are nor generated by MigraDoc.

This is the code I am using for printing:
Code:
try
            {
                Document document = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromFile(file);
                string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);

                MigraDoc.Rendering.DocumentRenderer doc = new DocumentRenderer(document);

                MigraDoc.Rendering.Printing.MigraDocPrintDocument print = new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
                print.PrinterSettings.PrinterName = "Dell MFP Laser 3115cn PS";
                print.Renderer = doc;
                print.Print();
            }
            catch (Exception e)
            {
                String msg = e.Message;
            }


The error message appears already at the first line "Document document..."

I am using the actual assemblies. What I am doing wrong?

Any hints are appreciated.

Thanks a lot in advance.

Kind regards,
Bjoern


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 27, 2012 11:17 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!
Bjoern wrote:
What I am doing wrong?
The DdlReader can read MigraDoc DDL files.
It cannot read PS or PDF files.

To print PDF files, try the PdfFilePrinter class.

Or print directly from MigraDoc instead of creating a PDF file (currently this works with the GDI+ build only).
viewtopic.php?p=6083#p6083

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2012 9:56 am 
Offline

Joined: Mon Aug 27, 2012 8:23 am
Posts: 3
Thanks for your feedback.

The PdfFilePrinter class uses Acrobat(Reader) it is not installed and will never be.

So I have tried to print directly from MigraDoc (additional to creating a PDF because it's needed too):

Code:
MigraDoc.Rendering.DocumentRenderer doc = new DocumentRenderer(myDocument);
MigraDoc.Rendering.Printing.MigraDocPrintDocument print = new MigraDoc.Rendering.Printing.MigraDocPrintDocument();
print.PrinterSettings.PrinterName = "Dell MFP Laser 3115cn PS";
print.Renderer = doc;
print.Print();


Unfortunately nothing happens. The name of the printer I had copied and pasted directly from system information so I think it is correct.

Is this the right way or could it a problem with the configuration of my workstation?

Thanks in advance!

Kind regards
Bjoern


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2012 2:33 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
You can invoke the Windows dialog to fill the PrinterSettings.

Code:
PrinterSettings printerSettings = new PrinterSettings();

using (PrintDialog dialog = new PrintDialog())
{
  dialog.PrinterSettings = printerSettings;
  dialog.AllowSelection = true;
  dialog.AllowSomePages = true;
  dialog.ShowDialog();
}


This way you will see what's inside and how you have to specify printer name, printer port and such.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 31, 2012 6:19 am 
Offline

Joined: Mon Aug 27, 2012 8:23 am
Posts: 3
I have tried the PrintDialog and the name I used is correct.

Unfortunately nothing happens if I call Print() on my document. I have tried to print on my local PDFCreator too.
It absolutely happens nothing!?

But the PDF-Document itself is saved as expected.

Any hints?

Kind regards
Bjoern


Top
 Profile  
Reply with quote  
PostPosted: Sun Aug 24, 2014 1:40 pm 
Offline

Joined: Sun Aug 24, 2014 1:17 pm
Posts: 1
On 64 bit platforms, be sure to set dialog.UseEXDialog to value true, else the dialog will not show (see here for MSDN info).


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 293 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