On Wed, 2022-05-25 at 21:42 +0800, Mark Hung wrote: > here is another precondition: OutputDevice must be a printer (bPrt > ==true) I think this requires that "Use printer metrics for document formatting" is enabled to get to this path (tools, options, writer, compatibility) which I think is "PrinterIndependantLayout" of "disabled" in the config setting in the file format. If I create a new document, enable that "use printer metrics", add some text and then use the "file, print" dialog and I get a hit of bPrt of true. If you can reproduce the same I think that backtrace is valuable to you to attempt a test, e.g. PrintOrPDFExport(pOut, ...) where I see pOut->GetOutDevType() is OUTPUT_PRINTER (unotxdoc.cxx:2962) so I'd guess something like a doc with "use printer metrics" enabled ScopedVclPtrInstance<Printer> printer, SwViewShell::PrintOrPDFExport(printer, ... might get you where you want to go