Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Problem Saving PDF as single page TIFFs

$
0
0
Hello!

I ran across something interesting today and thought I'd share. I had the following code in a project:

for (int i = 1; i <= pdfConverter.PageCount; i++)
{
pdfConverter.StartPage = i;
pdfConverter.EndPage = i;

var extension = Path.GetExtension(newFilePath);
var pageNum = String.Format("-{0:000}", i);
var newPagePath = newFilePath.Replace(extension, pageNum + extension);

pdfConverter.SaveAsTIFF(newPagePath, tiffSettings);
}

But, the StartPage kept getting reset to 1 causing the TIFFs to come out as multi-page. So, I tried the following on a whim and it worked. Any thoughts on why this happened?

for (int i = 1; i <= pdfConverter.PageCount; i++)
{
// This looks odd, but for unknown reasons, the StartPage would reset to 1 after it was assigned the value of i.
// Assigning the value of i to the EndPage and then assigning the value of EndPage to StartPage works, though.
pdfConverter.EndPage = i;
pdfConverter.StartPage = pdfConverter.EndPage;

var extension = Path.GetExtension(newFilePath);
var pageNum = String.Format("-{0:000}", i);
var newPagePath = newFilePath.Replace(extension, pageNum + extension);

pdfConverter.SaveAsTIFF(newPagePath, tiffSettings);
}

Viewing all articles
Browse latest Browse all 3131