Download and launch of pdf

Hey guys,.

So, I come across a situation where I need to download and launch a pdf in my application. I've already implemented lance using an Adobe pdf file call (and it works very well) but every time it will open the pdf file, I get an error "the document cannot be opened because it is corrupt or damaged. It seems therefore that my download process and saving the file pdf is wrong.

To download the pdf, I have simply make a request to the url and save the data returned in a file. Clearly, I don't have a good understanding on what do I do to download/save a pdf file. Here is how I currently save the pdf:

QByteArray pdfData = reply->readAll();

        QString url = reply->url().toString();

        QStringList urlSplit = url.split(".");
        QString fileType = urlSplit.at(urlSplit.length()-1);

        QByteArray bytes;
        bytes.append(url);

        QString fileName = QString(QCryptographicHash::hash(bytes, QCryptographicHash::Md5).toHex()) + "." + fileType;

        QString fileTargetUrl = QDir::currentPath() + "/data/downloads/" + fileName;

        QFile textFile(fileTargetUrl);
        textFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);

        QTextStream textOut(&textFile);

        textOut << pdfData;

        textOut.flush();
        textFile.close();

Is there something wrong with the way I do things? If so, what can I change to correctly download the pdf?

Thanks for any possible help,

-Jeff

OK, so I found the problem. First convert it the reply-> readAll() in a QByteArray caused an error with the data of the pdf (bribery of encoding of pdf files). If the answer is directly inserted in the data file are not getting corrupted.

Here is the code works:

QString url = reply->url().toString();

QStringList urlSplit = url.split(".");
QString fileType = urlSplit.at(urlSplit.length()-1);

QByteArray bytes;
bytes.append(url);

QString fileName = QString(QCryptographicHash::hash(bytes, QCryptographicHash::Md5).toHex()) + "." + fileType;

QString fileTargetUrl = QDir::currentPath() + "/data/downloads/" + fileName;

QFile textFile(fileTargetUrl);
textFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);

textFile.write(reply->readAll());
textFile.flush();
textFile.close();

-Jeff

Tags: BlackBerry Developers

Similar Questions

  • I have an annual subscription to Adobe export in PDF, but my computer died and I am setting up a new computer. I also need to download Adobe Reader or Acrobat to download and open the PDF files?

    I export to PDF, but can't seem to download and open the PDF files. I need to download something?

    Hi Lisa,

    To download PDF files, you have nothing else except a web browser.
    However, to open the pdf file that is downloaded, you certainly need to download Acrobat Reader: Adobe - Adobe Acrobat Reader DC Distribution

    Kind regards

    Rahul

  • I have Photoshop CS6 and just signed up for one CC application. How to download and launch Photoshop CC?

    I have Photoshop CS6 and just signed up for one CC application. How to download and launch Photoshop CC?

    CC of Photoshop is not yet available. Next Monday!

    Mylenium

  • Download and view files PDF IOS 9.2

    Since downloading the iOS 9.2 update, I've noticed that I'm unable to download and view pdf files. I tried my account on my phone of colleagues (running iOS 9.1) that does it without problem. The server is the Exchange 2003 server. Has anyone else seen elsewhere? Anyone know a fix?

    We are having the same problem with some PDFs on Exchange 2003. The workaround of Acrobat to download the full message and press open in the player does not work. One or more of the following actions occurs:

    • The PDF file is as is the download (circle progresses / completes)
    • Tapping/long-press the PDF icon does nothing
    • The error "cannot download the attachment"

     

    Temporary workaround on 6s 9.2: open in Outlook Web Access in Safari, tap and hold the link to the PDF, open in new tab temporary until access OWA is removed.

    Cannot open some PDF files:

    (JW) iPhone 6 s, iOS 9.2, Exchange 2003, no. AirWatch Agent (AWA)

    (RJ) 5 s, iOS 9.2, AWA 5.0.3

    (MC) 5 s, iOS 9.2, AWA 5.0.3

    Can open the PDF file, the others cannot:

    IPhone (KB) 6, iOS 8.3, Exchange 2003, AWA 5.0.3

    (SD/DEM) 6, iOS 9.2, Exchange 2010, AWA unk

    (MC) 6, iOS 9.1, Exchange 2003, no AWA

  • How to save downloaded and open the PDF directly into my laptop, compared to saving the file in the cloud? Can I remove DC and install Acrobat Reader, which is thin and easier to use for my needs and much, much more secure?

    Somehow, I downloaded and installed Adobe alleged DC update for the existing acrobat Reader installed on my laptop.

    DC app has been a disaster for me in terms of generation of convoluted navigation and extra work.

    In addition, I do NOT trust or want an application based on a cloud because of the deep and hard-learned risk, privacy and security, as well as the occasional loss of connectivity online and access, what urgent needs can get GROUND in terms of use of such an external cloud-based application.

    Issues related to the:

    [1] how to save a PDF downloaded and open directly on my laptop, a report file to save the file in the cloud and then copying it in the folder of the laptop? This process in several steps inside the DC is a frustrating PITA, as Adobe Acrobat Reader has been sufficient for my needs.

    can [2] Alternatively, I remove CD and install the latest version of Adobe Acrobat Reader, which is thin and easier to use for my needs and much, much more secure?

    Thank you very much in advance for the help and deliberate in a timely & the readers attention. Today is Tuesday, November 3, 2015.

    Kind regards

    Stephen H. Franke

    E-mail: shfranke@hotmail... com

    Hi stephenf95557665,

    (1) you can simply save the file on your computer as allows you to save in the older version of the player, it is not necessary to register I your cloud of document.

    If you save the file to the document cloud, you will be able to access any system from anywhere.

    (2) If you still think earlier version users need, then they can probably uninstall the last being & reinstall the old version using this link http://get.adobe.com/reader/enterprise/

    Kind regards
    Nicos

  • My laptop can not download and open online pdf files

    Hello

    My computer (WINDOWS 7 ULTIMATE {32 Bit}) done an update on February 27, now I can't open or download files special PDF Online.

    I tried to run the system restore point, but it does give me a DATE option that I want to restore.

    He gave me this option date March 3, 2015 only.

    Help, please!

    Hello
    Thanks for posting your questions about Microsoft Community.
    To help you better could you please clarify a number of things like:
    1. you try to download a .pdf file as an attachment to an email or a Web site hyperlink?
    2. What is the default browser installed on the computer?
    3. what actually happens when you try to download\open a pdf file?
    4. What is the management software pdf documents by default (such as Adobe reader or NitroPDF) installed on the machine?

     
    However, assuming you are using Acrobat or Adobe Reader on a system that includes a browser, you configure automatically the browser to open PDF files in the browser window. Acrobat and Adobe Reader install the ActiveX plugin files allow you to use Internet Explorer or AOL to open PDF files.
     
    If an application is installed, but do not open the PDF files in the browser window, then work through the following steps to configure the browser:
    To open PDF files in a browser window, the ActiveX folder should contain the following files: AcroPDF.dll, AcroIEHelper.dll and pdfshell.dll.
     
    ActiveX controls must be in: program files Files\Adobe\Acrobat\ActiveX
    If one of these files is missing, then repair Acrobat or Adobe Reader by choosing Help > repair Acrobat Installation or reinstall the application.
     
    Make sure that you use a version of your web browser, Acrobat and Adobe Reader supports, such as Internet Explorer. Supported for Adobe Acrobat 8, Adobe Reader 8 browsers are Internet Explorer 6.0, 6.0 SP1, Internet Explorer 7.0, Firefox 1.5 or later, Mozilla 1.7 and AOL 9.

    To make sure that the Windows registry provides the information that your web browser should display PDF files, restart Windows. If the Windows registry is not updated after the installation of Acrobat, then the web browser can not find the references it needs to access the PDF files on the web.

    Reinstall Acrobat or Adobe Reader.

    To ensure that the correct information of the plug-in is added to the Windows registry, reinstall Acrobat or Adobe Reader.If you want the browser to open PDFs in a separate Acrobat window, then configure the browser to use Acrobat or Adobe Reader as a helper application. Then, when you select a PDF file in Internet Explorer or AOL, the browser opens the PDF file in an Acrobat window instead of the browser window.
     

    To configure the browser to use Acrobat or Adobe Reader to open PDF files:
    1. close your web browser.
    2 start Acrobat or Adobe Reader.
    3 Choose Edition > Preferences.
    4. Select Internet in the list on the left.
    5 disable the display option IN the browser, and then click OK.
    6. restart Internet Explorer or AOL.

    Finally,.

    And there is also a possibility that the file association to open pdf files was damaged for some reason, then we will have Adobe Acrobat or Adobe Reader as default program and check if that helps. Please refer to:

     
    Note: The next time you select a link to a file PDF, the browser may prompt you to open or save the file. If you choose to open the file, then the browser opens the file in the support application that you specified. If you choose to save the file, the browser downloads the file to the hard drive.
     
    I hope this helps.
    Please get back to us with the required information, and we would be happy to help you.
     
    Kind regards.
  • Download and store the pdf file into a Local support

    I generated a PDF with top of desktop PC and uploaded to Adobe Acrobat DC via the Acrobat.com. I can preview in a cloud of Document by opening Adobe Acrobat is installed in the iPad.

    Question: How can I download the file and place it in a Local of the iPad support?

    Hi Kishida-san,

    Unfortunately, there is no this option, but once you download the file of cloud, a copy of it is saved on the device which you can access without internet connectivity.

    In addition, you cannot copy the file from the cloud to a specific folder on the device, but you can copy a file from local storage on the device to the cloud.

    In addition, this link appears corresponding to your query: https://forums.adobe.com/docs/DOC-5782

    Hope that helps

    Kind regards

    Rahul

  • Help download and launch of 13 items

    I just bought 13 items. I installed it and when I get to the launch area - it asks me to sign in - when I do--he's going nowhere - barely done turn the 4 boxes forever. It used open - help!

    12. does not elements

  • Why not download and read .pdf files

    I never had no problem download and playback of .pdf files to what I 'upgraded' Adobe reader version 11. Now all the downloads of attempts fail because "I don't have the necessary helper or same C:\DOCUME~1\Will-o\LOCALS~1\Temp\Back channel II - betrayal of the Viet Nam - ch. 1 & 2. PDF cannot be opened, because the associated helper application does not exist. Changing the association in your preferences. What in the world is happening and how to fix it?

    Under "Tools - Applications - Adobe Acrobat Document, the I chose 'Use Adobe Reader'." However since I also have Adobe Acrobat 8.3, I tried substitution, for the reader, but which does not work either. Help, please.

    You could try the following:

    (1) change your preference for 'Preview in Firefox' and use the download button to save the file. But it's an extra step.

    (2) change your preference to "Always ask" and see if you can get the file to open it in this way.

    (3) delete the file from your application's preferences (it is sometimes damaged) and try again. Note: these are only the preferences for which applications manage what types of content, not all your Firefox preferences.

    To do this:

    (i) open your current Firefox settings (AKA Firefox profile) folder using

    Help > troubleshooting information > "view file" button.

    (ii) switch back to Firefox and the output. Your Windows Explorer window should go back to the foreground. Pause while Firefox finishing its cleanup.

    (iii) and rename the mimeTypes.rdf something like mimeTypes.old

    (iv) restart Firefox. It is likely you will default to 'Preview in Firefox' and I hope that the paths for Adobe Reader and Adobe Acrobat will now be correct if you choose one of those.

    A little luck?

  • PDF files are downloading and not opening

    Firefox on Android has been; When you view a web page with a link to a file PDF would simply be you prompt to open it with, choose Acrobat and opening.

    Now, the ALWAYS PDF downloads - is not acceptable.

    It was working as expected 2 weeks or if there are; What has changed?

    PS - I tried the Add on PDF which kind of works, but the performance is so bad, that it is unusable.

    Hello PatL1701, automatic execution of downloaded content has been deleted because of security concerns: www.androidpolice.com/2013/09/11/security-firefox-for-android-can-be-tricked-into-automatically-downloading-and-executing-malicious-code/

  • Have HP laptop and a Dell A960 printer, I can't get the driver downloaded to launch the printer

    I have a HP laptop and a printer Dell A960, I can't get the driver downloaded to launch the printer is it possible or I'm wasting my time.

    Hi ChrisDuBay,

    ·         What version of the operating system is installed on the computer?

    ·         What happens when you try to download the printer drivers?

    ·         You receive an error message?

    ·         How do you install the printer?

    I suggest you to see the links.

    http://support.Dell.com/support/topics/global.aspx/support/KCS/document?c=us&l=en&s=Gen&docid=DSN_332365&isLegacy=true

    http://support.Dell.com/support/topics/global.aspx/support/product_support/en/printers/AIO?c=us&l=en&s=Gen& ~ section = 003

  • Downloading and opening and saving pdf attachments to emails problem

    I downloaded the adobe reader 8.0 software to save and open PDFs from attachments in emails. I received an email with a pdf attachment in my yahoo email. I tried the open and save the pdf attachment in the email, and the file is not down load or open or save.  My internet browser is internet explorer 8. My operating system is Windows Vista. My computer is a Dell.  I get no error message, attachment simply refuses to download or save or open.  I checked with the sender of the e-mail and its attachment of pdf file, and they didn't put no restrictions on download save or open the attached pdf file.

    Hello

    Download the latest Acrobat Reader which is 9.x

    Acrobat Reader
    http://get.Adobe.com/reader/

    Uncheck the Google toolbar, unless you want really (not recommended)

    Download - SAVE - go to where you put it-click on - RUN AS ADMIN

    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

  • Why did take more than 15 minutes and always my PDF conversion is not downloaded?

    Why did take more than 15 minutes and always my PDF conversion is not downloaded?

    Hi Karen,.

    Try to convert by using the web Interface using this URL: https://cloud.acrobat.com

    Kind regards
    Rahul

  • Since the new downloaded drive, display a pdf file was DOWNGRADED.  The color contrast is terrible and the quality of the screen reminds me of the first BACK operation displays. Help!  I want the quality looks an old back!

    Since the new downloaded drive, display a pdf file was DOWNGRADED.  The color contrast is terrible and the quality of the screen reminds me of the first BACK operation displays. Help!  I want the quality looks an old back!

    To add to this miserable viewing experience, we cannot even e-mail Adobe to communicate this déclassé experience.  We are forced to complain to others.

    Who knows of another pdf viewer application which is better (for viewing - what are the tools when he drove you nuts just to see your documents in Adobe reader?)

    Well, finally found.  Go to the edition/preferences/display Page.  Under "Rendering: smooth text", choose "for computer/laptop LCD screens". "  Do not know why the default value is set to 'none', which gives you this mess / hard to read test.

  • How to download and install PDF pack all the

    I am registered and paid but do not know how to download and install

    Adobe PDF is an online service.

    Please visit:https://helpx.adobe.com/document-cloud/help/using-pdfpack.html

    I hope this helps.

    Concerning

    Megha Rawat

Maybe you are looking for

  • How can I recover toolbar? I fall by chance

    How can I recover my toolbar? I fall by chance

  • My laptop has a remove-able CPU?

    Hello. I would like to know if my CPU can be replaced or is integrated. I plan on upgrading my CPU, I found one that is better and my motherboard supports. However, I can't order it until I know if my laptop CPU can be removed. Model of laptop: HP G6

  • How to combine pictures

    How can Hello and thanks for thinking of my question, that is, I put one pic above others and do a pic?  Using standards 'my photos' and you want to put a funny banner above funny to post on Facebook. I have ms works, but no office, tried to do doc,

  • BluetoothDemo does not

    HelloI have 2 blackberry bold 9000, os 5.Why the BluetoothDemo sample does not work in my phone? they are not able to communicate, even if I accept the client connection request Thanks in advance

  • I need to turn off CTRL + W so that it closes windows open on my desktop.

    A planning program I use for work to connect to a working computer and work remotely uses the function CTRL + W. Whenever I use it for my computer it closes my window open and I have to start all over again. I can't get my work done with CTRL + W dra