إضافة ومعالجة التذاكر المطبوعة
قم بإنشاء وتحرير وربط والحصول على تذاكر طباعة لملفات XPS عبر C++
في سياق ملفات XPS، بطاقة الطباعة هي مجموعة من الإرشادات التي تحدد كيفية طباعة المستند. إنه في الأساس ملف تكوين يحتوي على معلومات حول:
- أبعاد واتجاه الصفحات المطبوعة.
- يجب استخدام درج الورق أو وحدة التغذية.
- دقة وعمق الألوان للمخرجات المطبوعة.
- ما إذا كان سيتم الطباعة على كلا وجهي الورقة.
- الترتيب الذي يجب أن تتم به طباعة الصفحات وترتيبها.
- أي خيارات تشطيب إضافية، مثل التدبيس أو الربط أو الثقب.
ومن خلال فهم تذاكر الطباعة واستخدامها، يمكنك تحسين عملية الطباعة وتحقيق المخرجات المطلوبة لمستندات XPS الخاصة بك.
يتيح حل Aspose.Page API من بين الميزات الأخرى المختلفة العمل مع التذاكر المطبوعة. ستجد هنا معلومات تشرح كيفية إنشائها وتحريرها والحصول عليها وربطها. لمعالجة تذاكر الطباعة لملفات XPS، نحتاج إلى:
-Aspose.Page for C++ API وهو عبارة عن معالجة وتحويل المستندات غنية بالميزات وقوية وسهلة الاستخدام.
-افتح مدير الحزم NuGet، وابحث عن Aspose.Page وقم بالتثبيت. يمكنك أيضًا استخدام الأمر التالي من وحدة تحكم إدارة الحزم.
Package Manager Console Command
PM> Install-Package Aspose.Page
خطوات إنشاء تذكرة طباعة مخصصة C++.
- قم بتعيين المسار إلى دليل المستندات.
- قم بإنشاء ملف XPS باستخدام XpsDocument Class .
- أضف تذكرة طباعة مهمة مخصصة باستخدام منشئ JobPrintTicket .
- قم بإضافة مُهيئ معلمة صفحة مخصصة وخيار دقة صفحة مخصصة إلى التذكرة.
- احفظ مستند XPS الذي تم تغييره باستخدام طريقة XPsDocument.Save() .
إنشاء تذكرة طباعة مخصصة
// The path to the documents directory. | |
System::String dir = RunExamples::GetDataDir_WorkingWithPrintTickets(); | |
// Create new XPS document | |
{ | |
System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_0({ document}); | |
// ------------------------------------------ | |
try | |
{ | |
// Set a custom job-level print ticket | |
document->set_JobPrintTicket(System::MakeObject<JobPrintTicket>( | |
System::MakeArray<System::SharedPtr<IJobPrintTicketItem>>({ | |
// Specify input bin. | |
System::MakeObject<JobInputBin>(System::MakeArray<System::SharedPtr<InputBin::IInputBinItem>>({InputBin::InputBinOption::Manual->Clone()->Add(System::MakeArray<System::SharedPtr<InputBin::IInputBinOptionItem>>( | |
{InputBin::FeedFace::FaceDown, InputBin::FeedDirection::LongEdgeFirst, System::MakeObject<InputBin::MediaSheetCapacity>(100)}))})), | |
// Specify output bin. | |
System::MakeObject<JobOutputBin>(System::MakeArray<System::SharedPtr<OutputBin::IOutputBinItem>>({ | |
System::MakeObject<OutputBin::OutputBinOption>(System::MakeArray<System::SharedPtr<OutputBin::IOutputBinOptionItem>>( | |
{OutputBin::BinType::Sorter})), | |
System::MakeObject<OutputBin::OutputBinOption>(System::MakeArray<System::SharedPtr<OutputBin::IOutputBinOptionItem>>( | |
{OutputBin::BinType::Stacker, System::MakeObject<OutputBin::MediaSheetCapacity>(100)}))})), | |
// Specify page orientation. | |
System::MakeObject<PageOrientation>(System::MakeArray<System::SharedPtr<PageOrientation::PageOrientationOption>>( | |
{PageOrientation::PageOrientationOption::Landscape})), | |
// Specify duplex mode for the output. | |
System::MakeObject<JobDuplexAllDocumentsContiguously>(System::MakeArray<System::SharedPtr<Duplex::DuplexOption>>( | |
{Duplex::DuplexOption::TwoSidedLongEdge(Duplex::DuplexMode::Automatic)})), | |
// Specify the color settings for the output. | |
System::MakeObject<PageOutputColor>(System::MakeArray<System::SharedPtr<PageOutputColor::IPageOutputColorItem>>( | |
{PageOutputColor::PageOutputColorOption::Grayscale(0, 8)}))}))); | |
// Save the document with the custom job-level print ticket. | |
document->Save(dir + u"output1.xps"); | |
} | |
catch(...) | |
{ | |
__dispose_guard_0.SetCurrentException(std::current_exception()); | |
} | |
} |
خطوات تحرير تذاكر الطباعة XPS عبر C++.
- قم بتعيين المسار إلى دليل المستندات.
- افتح مستند XPS مع التذاكر المطبوعة باستخدام XpsDocument Class.
- لإزالة المعلمات غير المطلوبة من التذكرة، استخدم الطريقة Remove() .
- احفظ المستند باستخدام تذكرة طباعة المهمة التي تم تغييرها عن طريق الأسلوب XPsDocument.Save().
تحرير تذكرة الطباعة
// The path to the documents directory. | |
System::String dir = RunExamples::GetDataDir_WorkingWithPrintTickets(); | |
// Open XPS Document with print tickets | |
System::SharedPtr<XpsDocument> xDocs = System::MakeObject<XpsDocument>(dir + u"input3.xps"); | |
System::SharedPtr<JobPrintTicket> pt = xDocs->get_JobPrintTicket(); | |
// Remove some parameters from job print ticket | |
pt->Remove(System::MakeArray<System::String>({u"ns0000:PageDevmodeSnapshot", u"ns0000:JobInterleaving", u"ns0000:JobImageType"})); | |
// Add some parameters to job print ticket | |
pt->Add(System::MakeArray<System::SharedPtr<IJobPrintTicketItem>>({System::MakeObject<JobCopiesAllDocuments>(2), | |
System::MakeObject<PageMediaSize>(System::MakeArray<System::SharedPtr<PageMediaSize::IPageMediaSizeItem>>({PageMediaSize::PageMediaSizeOption::ISOA4}))})); | |
// Save the document with changed job print ticket. | |
xDocs->Save(dir + u"output3.xps"); |
خطوات الحصول على التذاكر المطبوعة عبر C++.
- قم بتعيين المسار إلى دليل المستندات.
- افتح مستند XPS مع التذاكر المطبوعة باستخدام XpsDocument Class.
- قم بإنشاء تذكرة طباعة المهمة باستخدام المُنشئ JobPrintTicket.
- قم بإنشاء تذكرة طباعة المستند باستخدام طريقة GetDocumentPrintTicket() .
- احصل على تذكرة طباعة الصفحة باستخدام طريقة GetPagePrintTicket() .
- احفظ المستند مع تذكرة طباعة المهمة التي تم تغييرها عن طريق الأسلوب XPsDocument.Save().
احصل على تذكرة مطبوعة
// The path to the documents directory. | |
System::String dir = RunExamples::GetDataDir_WorkingWithPrintTickets(); | |
// Open XPS Document without print tickets | |
System::SharedPtr<XpsDocument> xDocs = System::MakeObject<XpsDocument>(dir + u"input1.xps"); | |
// Get job print ticket | |
System::SharedPtr<JobPrintTicket> jobPrintTicket = xDocs->get_JobPrintTicket(); | |
// must be null for this document | |
// Get document print ticket | |
System::SharedPtr<DocumentPrintTicket> docPrintTicket = xDocs->GetDocumentPrintTicket(1); | |
// must be null for this document | |
// Get page print ticket | |
System::SharedPtr<PagePrintTicket> pagePrintTicket = xDocs->GetPagePrintTicket(1, 1); | |
// must be null for this document | |
// Save the document. Default print tickets are automatically added to document while saving. | |
xDocs->Save(dir + u"output1.xps"); | |
// Open saved earlier XPS Document with print tickets | |
System::SharedPtr<XpsDocument> xDocs2 = System::MakeObject<XpsDocument>(dir + u"output1.xps"); | |
// Print tickets must not be null | |
System::Console::WriteLine(xDocs2->get_JobPrintTicket()); | |
System::Console::WriteLine(xDocs2->GetDocumentPrintTicket(1)); | |
System::Console::WriteLine(xDocs2->GetPagePrintTicket(1, 1)); |
خطوات ربط تذاكر الطباعة لملف XPS عبر C++.
- قم بتعيين المسار إلى دليل المستندات.
- قم بإنشاء ملف XPS جديد وافتح مستند XPS مع تذاكر الطباعة باستخدام XpsDocument Class.
- افتح مستند XPS مع التذاكر المطبوعة باستخدام XpsDocument Class
- قم بربط تذكرة طباعة المهمة بمنشئ JobPrintTicket.
- اربط تذكرة طباعة المستند باستخدام طريقتي GetDocumentPrintTicket() و SetDocumentPrintTicket()
- اربط تذكرة طباعة الصفحة باستخدام طريقتي GetPagePrintTicket() و SetPagePrintTicket() .
- احفظ المستند مع تذكرة طباعة المهمة التي تم تغييرها عن طريق طريقة XPsDocument.Save().
ربط تذكرة الطباعة
// The path to the documents directory. | |
System::String dir = RunExamples::GetDataDir_WorkingWithPrintTickets(); | |
// Create new XPS document | |
System::SharedPtr<XpsDocument> xDocs1 = System::MakeObject<XpsDocument>(); | |
// Open XPS Document with print tickets | |
System::SharedPtr<XpsDocument> xDocs2 = System::MakeObject<XpsDocument>(dir + u"input2.xps"); | |
// Link job print ticket | |
xDocs1->set_JobPrintTicket(xDocs2->get_JobPrintTicket()); | |
// Link document print ticket | |
xDocs1->SetDocumentPrintTicket(1, xDocs2->GetDocumentPrintTicket(2)); | |
// Link page print ticket | |
xDocs1->SetPagePrintTicket(1, 1, xDocs2->GetPagePrintTicket(3, 2)); | |
// Save the document with linked print tickets. | |
xDocs1->Save(dir + u"output1.xps"); |
XPS ما هو XPS تنسيق الملف
تنسيق XPS مشابه لتنسيق PDF. كلاهما عبارة عن تنسيقات لغة وصف الصفحة (PDL). يعتمد EPS على HTML وليس على لغة PostScript. يمكن أن يحتوي ملف .eps على ترميز لهيكل المستند بالإضافة إلى معلومات حول الشكل الذي سيبدو عليه المستند. هناك أيضًا إرشادات مضافة حول كيفية طباعة المستند وتقديمه. تتمثل ميزة التنسيق في أنه يعمل على إصلاح وصف المستند مما يعني أنه سيبدو كما هو بغض النظر عن من ومن أي نظام تشغيل يفتحه.