이 방법 자습서에서는 C#에서 OTG를 PDF로 변환하는 방법을 보여줍니다. C# 응용 프로그램을 사용하여 OTG를 PDF로 변환하는 것은 .NET용 Aspose.Imaging의 도움으로 몇 가지 간단하고 쉬운 단계로 수행할 수 있습니다.
C#에서 OTG를 PDF로 변환하는 단계
- Aspose.Imaging for .NET NuGet 패키지 설치
- Aspose.Imaging, Aspose.Imaging.ImageOptions 및 Aspose.Imaging.FileFormats.Pdf 네임스페이스 포함
- Aspose.Imaging.License 클래스를 사용하여 Aspose 라이선스 설정
- Image.Load 메서드를 사용하여 OTG 파일 로드
- PdfOptions 클래스를 사용하여 PDF 파일 옵션 설정
- PdfDocumentInfo 클래스를 사용하여 PDF 메타데이터 정보 설정
- 저장 방법 및 PdfSaveOptions를 사용하여 출력 PDF 저장
위의 5단계와 6단계에서 입력 OTG graphics file에서 변환될 출력 PDF의 정보와 속성을 설정하고 있습니다.
C#에서 OTG를 PDF로 변환하는 코드
using System; | |
//Add Aspose.Imaging for .NET package reference | |
//Use following namespaces to convert OTG to PDF format | |
using Aspose.Imaging; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.FileFormats.Pdf; | |
namespace ConvertOTGToPDF | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Set Aspose license before converting an OTG graphics template to PDF | |
//using Aspose.Imaging for .NET | |
Aspose.Imaging.License AsposeImagingLicense = new Aspose.Imaging.License(); | |
AsposeImagingLicense.SetLicense(@"c:\asposelicense\license.lic"); | |
//Load OTG template to be converted to PDF in a new Image object | |
Image ConvertOTGGraphicsToPDF = Image.Load("Input_Graphics_Template.otg"); | |
//create PdfOptions instance to set properties for output PDF | |
PdfOptions PDFSaveOptions = new PdfOptions(); | |
//set output PDF compliance setting | |
PDFSaveOptions.PdfCoreOptions.PdfCompliance = PdfComplianceVersion.PdfA1a; | |
//set output PDF resolution settings to 72 dpi horizontal and vertical | |
PDFSaveOptions.ResolutionSettings = new ResolutionSetting(72, 72); | |
//specify settings for the meta data of the output PDF file | |
PdfDocumentInfo PDFMetadataInfo = new PdfDocumentInfo(); | |
PDFMetadataInfo.Author = "Author Name"; | |
PDFMetadataInfo.Keywords = "Convert OTG to PDF, OTG to PDF"; | |
PDFMetadataInfo.Subject = "Convert OTG to PDF in C#"; | |
//set PDF document information to the set metadata | |
PDFSaveOptions.PdfDocumentInfo = PDFMetadataInfo; | |
//save converted output PDF file with specified save options | |
ConvertOTGGraphicsToPDF.Save("PDFConvertedFromOTG.pdf", PDFSaveOptions); | |
} | |
} | |
} |
위의 코드 조각을 사용하여 Windows 데스크톱, ASP.NET 웹 또는 콘솔 응용 프로그램을 포함한 .NET 프로젝트의 C# 코드에서 자신만의 OTG를 PDF로 변환기를 쉽게 만들 수 있습니다.