PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 4:04 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Fri Mar 14, 2008 8:23 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 17, 2008 10:13 am 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 17, 2008 3:20 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 18, 2008 1:36 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 18, 2008 2:01 pm 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 18, 2008 2:24 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 18, 2008 2:32 pm 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 18, 2008 3:00 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 19, 2008 11:59 am 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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 );
}


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 19, 2008 1:06 pm 
Offline

Joined: Thu Jan 24, 2008 8:52 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 20, 2022 7:51 pm 
Offline
Supporter

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 50
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 ?


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

All times are UTC


Who is online

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