Troubleshooting WriteJPEG issues - no file created

  • Hello,

    I am converting a page from PDF file to a JPEG with the following code.

    TempImageFileName := CreateTempFilePath('PDFImport.jpg');
    WPViewPdf.WriteJPEG(TempImageFileName, Pg, 300, 0);
    TGraphicEditor(FDoc.docEditor).LoadImageFile(TempImageFileName);
    DeleteFile(TempImageFileName);

    On some computers - some of the time I don't get a file created. At this time it seems to be random. I can see the page in the viewer just fine, but the jpeg file is never created.

    I have two customers that this happens to consistently. I have used process monitor from the sysinternals suite to try and see where things are failing. I can see the temp file name opened but nothing is ever written to the file.

    I also checked and the correct dll seems to be loaded (we install the dll in the same directory as our exe).

    And the preview in the component does correctly draw the thumbnail of the page.

    Any ideas on what could be happening or other steps I can take on the computers where this is not working?

    Thanks,

    Mark

    • Offizieller Beitrag

    Hi,

    It could be a memory issue. If you set 300dpi thats a pretty big JPEG file.

    You can try to reduce the resolution or use WriteBitmap. Using WriteBitmap you can also specify the desired width in pixels.

    As alternative - the PrintHDC method of V3 works pretty good and is internally also used by the bitmap creation. Using it you have the maximum control over the process.

    There is a demo which shows how to use it.

    Julian

  • The resulting jpg files are normally around 400K. I guess I didn't think that would be too big.

    But I completely missed the fact that version 3 was released. Let me get the upgrade and see what happens.