tôi cố gắng để in ra nội dung của biên tập viên của tôi:trang cấp-Vấn đề ở In tài liệu
PrintDialog pd = new PrintDialog();
pd.PageRangeSelection = PageRangeSelection.AllPages;
pd.UserPageRangeEnabled = true;
FlowDocument fd = DocumentPrinter.CreateFlowDocumentForEditor(CurrentDocument.Editor);
DocumentPaginator dp = ((IDocumentPaginatorSource)fd).DocumentPaginator;
bool? res = pd.ShowDialog();
if (res.HasValue && res.Value)
{
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWidth;
fd.PagePadding = new Thickness(50);
fd.ColumnGap = 0;
fd.ColumnWidth = pd.PrintableAreaWidth;
pd.PrintDocument(dp, CurrentDocument.Editor.FileName);
}
Các thử nghiệm tài liệu tôi đã từng có khoảng 14 trang (với điều này pagesize-settings). tôi đã thử nghiệm nó: printdialog xuất hiện và tôi đã chọn một pagerange (tôi gõ "1-3" vào hộp văn bản) và nhấp print
. phía trên printdocument()
Tôi đặt điểm ngắt và nhìn vào đối tượng printdialog. nó nói pd.PageRangeSelection = PageRangeSelection.UserPage
và pd.PageRange = {1-3}
. Tôi đoán điều này là đúng, bởi vì tôi chỉ muốn in trang 1-3. sau đó thực hiện printdocument()
và trong đầu ra-pdf (để kiểm tra tôi sử dụng máy in pdf) có 14 trang (toàn bộ tài liệu được in).
sai lầm của tôi ở đâu? tại sao cài đặt pagerange không hoạt động?
nhờ sự giúp đỡ của bạn
đây không phải là lý do. tôi đã nói rằng tôi đã gỡ lỗi nó và PageRangeSelection-Property được đặt thành UserPages trước khi PrintDocument() - Phương thức được thi hành – 0xDEADBEEF