I use MigraDoc to programmatically create a PDF file with text, images and tables.
I need to set the Document Orientation (for all pages) of a document object to Landscape .
So, I tried the following.
document.DefaultPageSetup.Orientation = Orientation.Landscape;
But I get the following debug approval error.
--------------------------- Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue --------------------------- DefaultPageSetup must not be modified
If I click Ignore , it will pass, and Orientation really Landscape .
However, I want to make sure I'm doing it right.
So the question is, how do I set the document orientation for all pages in a Document using the MigraDoc library?
Here is the rest of the code (so that it helps you get the context)
using System.Runtime.Remoting.Messaging; using MigraDoc.DocumentObjectModel; namespace MyNamespace.PdfReports { class Documents { public static Document CreateDocument() {
Thank you very much! -Shiva
UPDATE:
SOLUTION: Here's a working code based on Thomas ' below (in the interest of others who may be looking for this solution).
// Create a new MigraDoc document Document document = new Document(); //... //...... PageSetup pageSetup = document.DefaultPageSetup.Clone(); // set orientation pageSetup.Orientation = Orientation.Landscape; // ... set other page setting you want here...