Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For some strange reason, PdfSharp seems not to behave the same with both the following:</p> <p>Example 1 - It doesn't seem to associate the instance of PdfPage class to the PdfDocument even though the page settings are correct while calling and after having called the PdfDocument.Save() method.</p> <pre><code>var pdfDoc = new PdfDocument(); var pdfPage = pdfDoc.AddPage(); pdfPage.Orientation = PdfSharp.PageOrientation.Landscape; pdfPage.Size = PdfSharp.PageSize.Letter; pdfPage.Rotate = 0; pdfDoc.Save(filename); </code></pre> <p>Example 2 - The same here...</p> <pre><code>var pdfDoc = new PdfDocument(); pdfDoc.Pages.Add(); pdfDoc.Pages[0].Orientation = PdfSharp.PageOrientation.Landscape; pdfDoc.Pages[0].Size = PdfSharp.PageSize.Letter; pdfDoc.Pages[0].Rotate = 0; pdfDoc.Save(filename); </code></pre> <p>Example 3 - This seems to have solved my problem</p> <pre><code>var pdfPage = new PdfPage(); pdfPage.Orientation = PdfSharp.PageOrientation.Landscape; pdfPage.Size = PdfSharp.PageSize.Letter; pdfPage.Rotate = 0; var pdfDoc = new PdfDocument(); pdfDoc.Pages.Add(pdfPage); pdfDoc.Save(filename); </code></pre> <p>Anyone has any idea of what am I missing here? I seem to do the same in either of these examples, as far as I'm concerned.</p> <p>Solution is:</p> <pre><code>var pdfPage = new PdfPage(); pdfPage.Size = PdfSharp.PageSize.Letter; pdfPage.Orientation = PdfSharp.PageOrientation.Landscape; pdfPage.Rotate = 0; var pdfDoc = new PdfDocument(); pdfDoc.Pages.Add(pdfPage); pdfDoc.Save(filename); </code></pre> <p>Set size first.</p> <p>Thanks for any comments and/or answers!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload