JohnDoe1

Hi,


the Add Watermark Sample from Feng Yuan seems to write only portrait pages as output, even when the (original) source-document contains landscape pages...

http://blogs.msdn.com/fyuan/archive/2006/08/23/715938.aspx

Does anyone have a solution for landscape pages or knows why it doesn't work for them




Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Brad Smith

<bump>

I'd like to see an answer to this too, along with everybody else trying to use this sample, I'm sure.

Brad.




Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

just a wild guess, but maybe because you write out visuals to the batchwriter and the size of the new page is different to the original page then (8.5 * 96 / 11 * 96, FixedDocument/DocumentPaginator! ).

Adding a printticket with landscape to the page doesn't modify size (so you can see in the viewer) but it does print out the page correctly... at least... (c;





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Brad Smith

I'm not quite sure I'm fully comprehending what you're telling me, but I'm going to poke at that for a while and see if I can fix Feng's sample myself.

Brad.




Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball

Was a solution to the landscape problem ever posted I am trying to figure it out, but with regards to the blog example, there seems no way to set a size for a ContainerVisual or to set the size when writing the output using the SerializerWriterCollator. So the output always comes out portrait !

Is the solution to use a canvas object, instead of a ContainerVisual that I can then write to a new FixedPage ! !





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

Hi,


if you want to have the pages in correct size (also in the xps-viewer) then just add a simple printticket with the PageMediaSize set to the size of the FixedPage...


looked good in the viewer on quick test, however I haven't tested printing out the result xps file... maybe you need to set PageOrientation in the PrintTicket as well for printing...


maybe it helps...

regards,

Jo




Code Snippet

...

// Write out modified page
PrintTicket pt = new PrintTicket();
pt.PageMediaSize = new PageMediaSize(width, height);
vxpsd.Write(newpage, pt);

...






Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball

Hi,

Thanks a lot for the code, its exactly what I needed.

I now use the following...

Code Snippet

// Write out modified page

PrintTicket oPrintTicket = new PrintTicket();

oPrintTicket.PageMediaSize = new PageMediaSize( dWidth, dHeight );

oPrintTicket.PageOrientation = PageOrientation.Portrait;

if( dWidth > dHeight ) oPrintTicket.PageOrientation = PageOrientation.Landscape;

oSerializerWriterCollator.Write( oNewPage, oPrintTicket );

There is still the issue though, as you pointed out regarding the actual printing of the document. The xps displays correctly on screen however when printed the document is incorrectly orientated. It prints correctly, when you manually set the orientation in the print options. This is going to be unacceptable for users though, and awkward when having differently orientated pages within the same document.

Why is the page orientation ignored in the ticket

This blog entry http://blogs.msdn.com/xps/archive/2006/09/15/756302.aspx suggests that I may still be missing something from the code. I do not wish to scale down the content of the page to fit a portrait output, but wish to actually print in a Landscape orientation.

I'll keep hunting, but any help or tips would be very much appreciated.





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

manually setting the orientation in the print options really
you mean in the printerdrivers option dialog maybe this post helps you to set these options http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1607813&SiteID=1


I will have a look at it again when I'll find some time for... makes me curious now... (c;





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball

Jo0815 wrote:

manually setting the orientation in the print options really

Yip, I have to go to the printer drivers option dialog and set the orientation to get it to print out correctly. At least this is the behaviour in MS XPS Viewer (beta 2).

Will check out that post and see how it goes. Thanks again for your help!





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball

Just as a follow up to this issue. The issue is actually with the XPS standalone viewer that comes with the XPS Essential Pack. For whatever reason it ignores the page orientation setting.

Those users around here that are using the embedded ie viewer that comes with .Net 3.0 have no problems viewing or printing the document.

Should I report this problem to someone





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

Edit: Ah I see, I've tested it with IE-Viewer or with BatchWriter... not with the standalone viewer of EssentialPack...


maybe contact xpsinfo@microsoft.com... and ask them why the PageOrientation getting ignored...


but good to know the code I've posted fixed that sample... :-)

_________

hm... ! printing out the result does work for me, no problems with the orientation.

I had a document with 2 pages, first page was portrait and 2nd page was landscape and the printout of both documents (the original and the new create watermark document) works perfectly here...


And my code is similar/same as yours:


Code Snippet

// Write out modified page
PrintTicket pt = new PrintTicket();
pt.PageMediaSize = new PageMediaSize(width, height);
pt.PageOrientation = (width > height) PageOrientation.Landscape : PageOrientation.Portrait;
vxpsd.Write(newpage, pt);







Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball




Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

No problem... please post the answer if you get one from xpsinfo...

would be interesting to see if it's a bug in the standalone viewer or it just simply ignores the PrintTickets (which I assume)...





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Keith Ball

With regards to the email conversation we've had, seems like its a printer/viewer issue... However he does suggest there may be a solution !

Microsofts reply to the issue;

From: Ben Kuhn [mailto:xxxx@xxxx.com]
Sent: 29 June 2007 18:51
To: Keith Ball; XPS Information
Subject: RE: Page Orientation in XPS documents is ignored in XPS Viewer EP

I see that the PrintTicket is associated with the page content. XPS Viewer EP does not support page-level PrintTicket objects when printing to GDI-based printers. If you associate the PrintTicket with the document sequence instead, the orientation should be handled properly. When printing to XPS-aware printers, the page level settings should be handled properly.





Re: XML Paper Specification (XPS) Landscape??? (Feng Yuan - Modifying XPS Document: Add Watermark Sample)

Jo0815

ok, so the XpsViewer EP doesn't support those page-level printtickets, which I've assumend, but assigning orientation in the document sequence, wouldn't that mean the orientation is the same for all pages when printing