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

Printing via a PostScript printer driver
http://forum.pdfsharp.com/viewtopic.php?f=2&t=339
Page 1 of 1

Author:  dsmeltz [ Fri Mar 14, 2008 8:23 pm ]
Post subject:  Printing via a PostScript printer driver

We can not print a PDFSharp generated PDF to a printer using a PostScript printer driver. If we use a PCL printer driver then the PDF is printed, but when trying to use a PostScript driver, the printer is unable to print the PDF. Any ideas or suggestions on where to look in the PDFSharp code to attempt to fix this problem are greatly appreciated.

I know, 'Why not just use the PCL driver?' When you have a customer that doesn't want to change their printer driver you have to try and come up with another solution.

Author:  Thomas Hoevel [ Mon Mar 17, 2008 10:13 am ]
Post subject:  Re: Printing via a PostScript printer driver

dsmeltz wrote:
We can not print a PDFSharp generated PDF to a printer using a PostScript printer driver.

Does this happen will all PDF files created with PDFsharp or only with some?
Does this happen with all PostScript printer drivers or only with some?

What is happening when printing? Do you get empty pages, error messages, or no pages at all? Do you get errors while spooling the document?

Author:  dsmeltz [ Mon Mar 17, 2008 3:20 pm ]
Post subject: 

This is happening for all files created with PDFSharp and printed via a PostScript printer driver.

The problem can also be exhibited sometimes when you try to print from Adobe via a PostScript driver. Adobe generates a 'The document could not be printed' error.

We have seen this happen with at least three different PostScript drivers. They are Canon, Xerox and HP PostScript printer drivers. These are the only three printers we have available to test.

We always receive the first page. Most of the time we receive the second page, then it varies when you receive an error on the printer. Here are some examples of the printer errors from the Canon printer:
----------------------------
ERROR: invalidrestore
OFFENDING COMMAND: restore
STACK:

-savelevel-
39
212.64
----------------------------
ERROR: invalidrestore
OFFENDING COMMAND: restore
STACK:

-savelevel-
0
1.84126
2.72032
4.48654
4.48654
4.48654
4.48654
5.80127
-mark-
(Q21C1-3.)
----------------------------
ERROR: syntaxerror
OFFENDING COMMAND: (a list of binary characters)

STACK:

/;#################
true
true
false
----------------------------
ERROR: undefined
OFFENDING COMMAND: RBJOLB+Ar

STACK:
----------------------------


I have a file available for you to look at if you would like.

Author:  dsmeltz [ Tue Mar 18, 2008 1:36 pm ]
Post subject: 

Let me also add that we are concatenating PDF originated from different sources, which aren't PDFSharp. We are using PDFSharp for concatenation and bookmarking. We also add a page number on certain pages.

The original documents all print, without issue, via a PostScript print driver. It's only after they are concatenated and processed with PDFSharp that the PostScript printer driver problem is experienced.

Author:  Thomas Hoevel [ Tue Mar 18, 2008 2:01 pm ]
Post subject: 

dsmeltz wrote:
Let me also add that we are concatenating PDF originated from different sources, which aren't PDFSharp.

Maybe the bug fix described here can help you.

Can you open the concatened PDFs with different Acrobat Reader versions without error messages? (please scroll through the entire document because errors occur only when pages are rendered)

The bug discussed in the other thread was only reported by older versions of Reader (I think I tried versions 5 and 6), where Acrobat 8 silently ignored the errors.

Which technique do you use to concatenate the files? (is your code based on one of the samples?)

Author:  dsmeltz [ Tue Mar 18, 2008 2:24 pm ]
Post subject: 

I can successfully open and view all the pages of my test document in Acrobat Reader 6.

Here's how we are doing concatenation:

// Open the document to import pages from it.
using ( PdfDocument inputDocument = PdfReader.Open( tocItemInfo.FileName, PdfDocumentOpenMode.Import ) ) {
// Clear the bookmarks
if ( inputDocument.Outlines.HasOutline ) {
inputDocument.Outlines.Clear();
}

// Iterate pages
int count = inputDocument.PageCount;
for ( int idx = 0; idx < count; idx++ ) {
// Get the page from the external document...
PdfPage page = inputDocument.Pages[ idx ];
// ...and add it to the output document.
pdfDocument.AddPage( page );
}

inputDocument.Close();
}

I'll try the fix from the other thread and see if it makes a difference.

Author:  Thomas Hoevel [ Tue Mar 18, 2008 2:32 pm ]
Post subject: 

dsmeltz wrote:
I'll try the fix from the other thread and see if it makes a difference.

I'm afraid the fix can only help with "invalid token" error messages from Acrobat Reader.

Author:  dsmeltz [ Tue Mar 18, 2008 3:00 pm ]
Post subject: 

Yes, the fixes in the other thread didn't make a difference.

Any other suggestions as to why PDFSharp isn't generating PostScript printable PDF content?

Author:  dsmeltz [ Wed Mar 19, 2008 11:59 am ]
Post subject: 

I've narrowed the problem down to adding new objects to an existing document. Here's the code were using to add text to a page:

// Get an XGraphics object for drawing
using ( XGraphics gfx = XGraphics.FromPdfPage( page ) ) {
// Draw the text
gfx.DrawString( text, xFont, XBrushes.Black,
new XRect( left, top, right - left, bottom - top ),
XStringFormat.TopCenter );
}

Author:  dsmeltz [ Wed Mar 19, 2008 1:06 pm ]
Post subject: 

I've figured this out. We are using a Unicode font. 'Arial Unicode MS' to be exact, but I was failing to set the font encoding to 'Unicode'. So that's why PostScript print drivers where having issues with our generated documents.

Author:  gastan [ Thu Jan 20, 2022 7:51 pm ]
Post subject:  Re: Printing via a PostScript printer driver

I also started to have this issue recently. Have absolutely no idea why. Havent changed anything in a years.
My encoding is set to Unicode...
Any other ideas ?

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