Results 1 to 17 of 17

Thread: PDF to Image Converter

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: PDF to Image Converter

    Feel free to share more details about your project!
    Do you realize you are replying to a 14 year old post?

    In case anyone wanders into this post, the QPdf module contains the functionality needed to open a PDF document, navigate through it page by page, and render individual pages to a QImage using QPdfDocument. If you want to save the image to a file, QImage::save() will do that. If you want to display the page image on-screen, then QPainter::drawImage() will do that for you.

    There is no need for any external (non-Qt) code to accomplish this.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    May 2024
    Location
    India
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Re: PDF to Image Converter

    Hey hi, you should check the code because scaledsimage isn't being set correctly.

    Qt Code:
    1. pdfFile = LoadPDF(fixurl.absoluteFilePath(), page, large);
    2. if (pdfFile.isNull()) {
    3. QMessageBox::warning(0, "Error", "Failed to load PDF.");
    4. } else {
    5. QImage tImage = pdfFile.toImage();
    6. if (!tImage.isNull()) {
    7. tImage.save("output.png", "PNG", 100);
    8. } else {
    9. QMessageBox::warning(0, "Error", "Failed to convert QPixmap to QImage.");
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2024
    Location
    India
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Re: PDF to Image Converter

    Quote Originally Posted by nehakakar View Post
    Hey hi, you should check the code because scaledsimage isn't being set correctly.

    Qt Code:
    1. pdfFile = LoadPDF(fixurl.absoluteFilePath(), page, large);
    2. if (pdfFile.isNull()) {
    3. QMessageBox::warning(0, "Error", "Failed to load PDF.");
    4. } else {
    5. QImage tImage = pdfFile.toImage();
    6. if (!tImage.isNull()) {
    7. tImage.save("output.png", "PNG", 100);
    8. } else {
    9. QMessageBox::warning(0, "Error", "Failed to convert QPixmap to QImage.");
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    On the other hand you can also use any online image converter such as Image Converter and for compressor Jpeg Compressor, these are really good tool.

Similar Threads

  1. Unit Converter Widget
    By baray98 in forum Qt Programming
    Replies: 13
    Last Post: 17th December 2016, 16:06
  2. Replies: 6
    Last Post: 21st September 2009, 10:55
  3. hide image,once moused moved from image
    By yuvaraj.yadav in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2009, 08:16
  4. Replies: 3
    Last Post: 14th March 2007, 08:09
  5. Image Converter
    By deekayt in forum General Discussion
    Replies: 1
    Last Post: 30th October 2006, 21:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.