We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PrintLargePdf use ever the automatic tray

Hello,


When I use the PrintLargePdf, the PaperSource is not taken and the document is printed on automatic tray.

Here the code :
                using (PdfViewer viewer = new PdfViewer())
{
viewer.AutoResize = true; //print the file with adjusted size
viewer.AutoRotate = true; //print the file with adjusted rotation
viewer.PrintPageDialog = false;//do not produce the page number dialog when printing
                <span style="color:white;">System</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Drawing</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Printing</span><span style="color:#b4b4b4;">.</span><span style="color:#4ec9b0;">PrinterSettings</span> <span style="color:white;">ps</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:white;">System</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Drawing</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Printing</span><span style="color:#b4b4b4;">.</span><span style="color:#4ec9b0;">PrinterSettings</span>();

                <span style="color:#4ec9b0;">ImpressionParametre</span> <span style="color:white;">ip</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">GetParameterByUfCode</span>(<span style="color:white;">uf</span>)<span style="color:#b4b4b4;">.</span><span style="color:white;">Parametre</span>;

                <span style="color:white;">ps</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrinterName</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">ServerName</span> <span style="color:#b4b4b4;">+</span> <span style="color:#d69d85;">@"\"</span> <span style="color:#b4b4b4;">+</span> <span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrinterName</span>;
                <span style="color:#4ec9b0;">PaperSource</span> <span style="color:white;">paper</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">ps</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PaperSources</span>[<span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">TrayNumber</span>];
                <span style="color:white;">ps</span><span style="color:#b4b4b4;">.</span><span style="color:white;">DefaultPageSettings</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PaperSource</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">paper</span>;

                <span style="color:#4ec9b0;">PageSettings</span> <span style="color:white;">pgs</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:#4ec9b0;">PageSettings</span>();
                <span style="color:white;">pgs</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Margins</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:white;">System</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Drawing</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Printing</span><span style="color:#b4b4b4;">.</span><span style="color:#4ec9b0;">Margins</span>(<span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">MargeLeft</span>, <span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">MargeRight</span>, <span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">MargeTop</span>, <span style="color:white;">ip</span><span style="color:#b4b4b4;">.</span><span style="color:white;">MargeBottom</span>);

                <span style="color:#569cd6;">using</span> (<span style="color:#4ec9b0;">MemoryStream</span> <span style="color:white;">ms</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:#4ec9b0;">MemoryStream</span>(<span style="color:white;">pdfData</span>))
                {
                    <span style="color:white;">viewer</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrintLargePdf</span>(<span style="color:white;">ms</span>, <span style="color:white;">pgs</span>, <span style="color:white;">ps</span>);
                }

                <span style="color:white;">ri</span><span style="color:#b4b4b4;">.</span><span style="color:white;">EtatImpression</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">viewer</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrintStatus</span> <span style="color:#b4b4b4;">==</span> <span style="color:#569cd6;">null</span>;
                <span style="color:white;">ri</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Parametre</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">ip</span>;

                <span style="color:#569cd6;">if</span> (<span style="color:white;">viewer</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrintStatus</span> <span style="color:#b4b4b4;">!=</span> <span style="color:#569cd6;">null</span>)
                {
                    <span style="color:white;">ri</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Error</span> <span style="color:#b4b4b4;">=</span> (<span style="color:white;">viewer</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrintStatus</span> <span style="color:#569cd6;">as</span> <span style="color:#4ec9b0;">Exception</span>)<span style="color:#b4b4b4;">.</span><span style="color:white;">Message</span>;
                    <span style="color:white;">ri</span><span style="color:#b4b4b4;">.</span><span style="color:white;">DetailErreur</span> <span style="color:#b4b4b4;">=</span> <span style="color:white;">viewer</span><span style="color:#b4b4b4;">.</span><span style="color:white;">PrintStatus</span> <span style="color:#569cd6;">as</span> <span style="color:#4ec9b0;">Exception</span>;
                }
                <span style="color:white;">pdfData</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">null</span>;
            }</pre></div><div>This is exactly the same issue as http://www.aspose.com/community/forums/1/364697/user-defined-paper-source-for-printing-words-document/showthread.aspx on Aspose.Words</div><div>My solution runs on .Net 4.5 and I tried with Aspose.Pdf 8.7, 9.2.1 and 9.5. </div><div><br></div><div>How to resolve quickly this issue ?</div><div><br></div><div>Thank you.</div><div><br></div>

Ok, this is working by set pgs.PaperSource and not ps.DefaultPageSettings.PaperSource…

Hi there,


Thanks for your feedback. It is good to know that you have managed to resolve your issue. Please note PrinterSetting.PaperSources collection gets available trays that are available on the printer and assign to PaperSetting.PaperSource property.

pgs.PaperSource=ps.PaperSources[1];

Please keep using our API and feel free to ask any question or concern, we will be more than happy to extend our support.

Best Regards,