Converting DocX to PDF while preserving page level printer settings

I have a 2 page word document that prints the first page to one tray and the second page to another tray. I am aware of the complexities involved in that, including the fact that it won’t work on a different printer, and may not even work from a different machine. So let’s ignore those issues.

What I need to be able to do is convert this a PDF while retaining that printer tray information. We are using straightforward code to do the conversion:

Dim sDocXFile As String = "C:\Source\Different Trays.docx"
Dim sPdfFile As String = IO.Path.ChangeExtension(sDocXFile, "PDF")

Dim oDocWords As New Aspose.Words.Document(sDocXFile)

oDocWords.Save(sPdfFile, Aspose.Words.SaveFormat.Pdf)

But when we print the resulting PDF, everything comes from the same tray. Does the .Save() not keep those settings? Do we need to open the PDF afterwards and set the FirstPageInfo on each Generator.Section? Are these changes going to survive a PDF concatenation (using Aspose.PDF) later?


Please ZIP and upload your sample Word document here for testing. We will investigate the issue on our end and provide you more information.

I’ll attach my document, but it won’t actually work since you don’t have my printer. Different (8.6 KB) In order to confirm that the pdf prints correctly, you’d need to create your own.

I should also point out that the settings need to be present in the pdf. We don’t use PdfViewer for our PDF printing.


Does the following code help?

Document doc = new Document(MyDir + @"Different Trays.docx");

PdfSaveOptions opts = new PdfSaveOptions();
opts.ExportDocumentStructure = true;

doc.Save(MyDir + @"18.1.pdf", opts);

I have also converted your “Different Trays.docx” document to PDF by using MS Word 2016 and attached it here for your reference (see these PDF (163.3 KB)). Does “msw-2016.pdf” uses correct paper trays when printing on your end?

Do you know of any software that you can use to verify that paper tray values stored in Word document are preserved in generated PDF?

That code doesn’t work. Nor did the Word->PDF conversion that you tried from Word.

However, I tried saving it myself from Word and that didn’t work either.

Originally, I remember seeing that you could save some page settings in Adobe Acrobat, but having found someone with a license, it looks like printer tray isn’t one of those settings. Based on other information, it looks like the PDF spec in fact doesn’t contain any way to do what I want (which seems surprising). So I sent you on a while goose chase. My apologies. The only way to get this done seems to be to extract the Printer Settings from the word document using Aspose.Words.Document.GetPageInfo, and then pass that information in parallel with the pdf.

Thanks for your time.


Thanks for the details. In case you have further inquiries or need any help with Aspose.Words, please let us know.