كيفية تحويل OTG إلى PDF بجافا

يشرح هذا البرنامج التعليمي الموجز أساسيات كيفية ** تحويل OTG إلى PDF في Java **. سيمكنك من ** تصدير OTG إلى PDF في Java ** باستخدام بضعة أسطر من التعليمات البرمجية على أي نظام تشغيل مثل MS Windows أو Linux أو macOS. يمكن تكوين العديد من الخيارات وإعدادات التوافق في ملف PDF الناتج قبل التحويل من OTG.

خطوات تحويل OTG إلى PDF في Java

  1. قم بتثبيت Aspose.Imaging من مستودع Maven في مشروعك لتحويل OTG إلى PDF
  2. قم بتحميل ملف OTG للإدخال في كائن فئة Image
  3. قم بتهيئة كائن فئة PdfOptions لتعيين الخصائص لملف PDF الناتج
  4. اضبط إعداد التوافق لمخرج PDF باستخدام PdfComplianceVersion enum
  5. قم بتعيين دقة ملف PDF الناتج ومعلومات البيانات الأولية
  6. احفظ ملف PDF الناتج المحول من ملف OTG المدخل

في الخطوات المذكورة أعلاه ، قمنا بتحميل ملف OTG المصدر وقمنا بتهيئة مثيل فئة PdfOptions لتعيين خصائص ملف PDF الناتج. في هذه العملية * لتغيير OTG إلى PDF في Java * قمنا بتعيين بعض الخصائص بما في ذلك الدقة الأفقية والرأسية والبيانات الوصفية لملف الإخراج ولكن يمكن أيضًا تعيين العديد من الخصائص الأخرى.

كود لتصدير OTG إلى PDF بجافا

import com.aspose.imaging.License;
import com.aspose.imaging.ResolutionSetting;
import com.aspose.imaging.fileformats.pdf.PdfDocumentInfo;
import com.aspose.imaging.imageoptions.PdfOptions;
import com.aspose.imaging.Image;
public class ConvertOTGToPDFInJava {
public static void main(String[] args) {//main function for the ConvertOTGToPDFInJava class
// Set the Aspose.Imaging license to avoid trial version message in the output PDF file exported from OTG
License ImagingLicense = new License();
ImagingLicense.setLicense("Aspose.Imaging.lic");
// Load the input OTG sample file to be converted to a PDF file into an Image object
Image InputOTGFile = Image.load("Input_OTG.otg");
// Instantiate a PdfOptions class instance to set properties for the output PDF
PdfOptions PDFOptionsForOutputFile = new PdfOptions();
// Set the resolution settings of the output PDF file to 72 DPI
PDFOptionsForOutputFile.setResolutionSettings(new ResolutionSetting(72, 72));
// Specify the metadata information of the output PDF file like Author, Keywords, and Subject
PdfDocumentInfo PDFDocInfo = new PdfDocumentInfo();
PDFDocInfo.setAuthor("Document Author Information");
PDFDocInfo.setKeywords("Change OTG to PDF, OTG to PDF");
PDFDocInfo.setSubject("Export OTG to PDF in Java");
// Set the PDF document information for metadata
PDFOptionsForOutputFile.setPdfDocumentInfo(PDFDocInfo);
// Call the save function to generate output PDF file exported from the OTG
InputOTGFile.save("PDFConvertedFromOTG.pdf", PDFOptionsForOutputFile);
}
}

في نموذج التعليمات البرمجية هذا ، يتم تكوين الدقة الأفقية والرأسية ومعلومات البيانات الوصفية لملف PDF الناتج قبل تصدير * OTG إلى PDF في Java *. يمكنك تغيير قيم الدقة والامتثال والبيانات الوصفية وفقًا لمتطلباتك.

علاوة على ذلك ، يمكنك زيارة كيفية تحويل BMP إلى PNG في Java للتحقق من الميزات المختلفة للعمل مع الصور.

 عربي