Aspose를 처음 접했을 때 아래의 경우 도움이 필요합니다.
여러 개의 PDF를 Aspose를 사용하여 1 개의 PDF로 병합하고 싶지만 쉽게 할 수 있지만 문제는 PDF 크기를 200MB로 제한하고 싶습니다.
즉, 내 병합 된 PDF 크기가 200MB보다 큰 경우 PDF를 여러 PDF로 분할해야합니다. 예를 들어, 병합 된 PDF의 크기가 300MB이면 첫 번째 PDF는 200MB이고 두 번째 PDF는 100MB이어야합니다.Aspose를 사용하여 크기에 따라 PDF 병합
주요 문제는 아래의 코드에서 문서의 크기를 찾을 수 없다는 것입니다. 아래 코드를 사용하고 있습니다. 크기에 따라 PDF를 병합
Document destinationPdfDocument = new Document();
Document sourcePdfDocument = new Document();
//Merge PDF one by one
for (int i = 0; i < filesFromDirectory.Count(); i++)
{
if (i == 0)
{
destinationPdfDocument = new Document(filesFromDirectory[i].FullName);
}
else
{
// Open second document
sourcePdfDocument = new Document(filesFromDirectory[i].FullName);
// Add pages of second document to the first
destinationPdfDocument.Pages.Add(sourcePdfDocument.Pages);
//** I need to check size of destinationPdfDocument over here to limit the size of resultant PDF**
}
}
// Encrypt PDF
destinationPdfDocument.Encrypt("userP", "ownerP", 0, CryptoAlgorithm.AESx128);
string finalPdfPath = Path.Combine(destinationSourceDirectory, destinatedPdfPath);
// Save concatenated output file
destinationPdfDocument.Save(finalPdfPath);
다른 방법도 알 수있다.
덕분에 사전