Hello VeryPDF,
We just purchased the upgrade for the toolkit for PDFToImage and i've encountered an odd occurance.
It appears in the new version when I convert a multipage PDF file to a PNG file (and specify I only want the first page by setting the last two parameters to 1,1) it renames my output file to "outputfile+0001.png". I understand why this would be desired if there was more than one page desired, but I only need to make a thumbnail of the 1st page and want it to name the file what I specified in the output parameter.
Example:
CString sSinglePagePNG = "output.png";
PDFToImageConverter(sMultiPagePDF, sSinglePagePNG, NULL, NULL, 100, 100, 24, COMPRESSION_PACKBITS, 25, 1, 0, 1, 1);
Result:
output0001.png
Can I get back the original name I specified somehow since I just want the first page?
Thanks,
===============================================
Hello VeryPDF,
I wrote some code to counteract the alteration of the output file. Feel free to add it to your package if you wish.
(I am assuming here you always give the extracted page a 4 character minimum length page number, which is what i'm witnessing).
BOOL CBrowserRequest::PDFToImageConverterSinglePage(CString sPDFFilePath,CString sImageFilePath,int nPage)
{
PDFToImageSetCode("XXXXXXXXXXXXX");
int nResult = PDFToImageConverter(sPDFFilePath, sImageFilePath, NULL, NULL, 100, 100, 24, COMPRESSION_PACKBITS, 25, 1, 1, nPage, nPage);
//Confirm file exists//
BOOL bFileExists = ( GetFileAttributes( sImageFilePath ) != INVALID_FILE_ATTRIBUTES );
if (!bFileExists)
{
//VeryPDF might have converted the name to original+000+nPage
CString sPage;
sPage.Format("%04i",nPage);
long nFound = sImageFilePath.ReverseFind('.');
CString sPageImagePath="";
if (nFound >= 0)
sPageImagePath = sImageFilePath.Left(nFound);
sPageImagePath += sPage + ".PNG";
bFileExists = ( GetFileAttributes( sPageImagePath ) != INVALID_FILE_ATTRIBUTES );
if (bFileExists)
rename(sPageImagePath,sImageFilePath);
else
return FALSE;
}
return TRUE;
}
Thanks,
===================================
Thanks for your great information, we will post your code to our Knowledge Base shortly, your sample source code will helpful for most of our customers, thank you again.
VeryPDF