Active5 years, 6 months ago
Here is my code:
If you read my first answer, it was modified 2008. Anyway, I did it again. No help, and same result with Delphi IDE running. I will use pdfcreator, works fine with that, as with any other printer, just adobe pdf fails to print. Edit, enhance, secure, merge, split, view, print PDF and AcroForms documents. PDFtoolkit allows you to save a PDF document to a memory stream. Blob DB field - how to save, retrieve and view pdf? (I am using Firebird 2, IBO TDataset compatible data access components. FrxPDFExport.Stream:= PDF; RepPurchaseOrder.Export(frxPDFExport). WPViewPDF is a powerful component which allows you to view and print PDF data. The data can be loaded from memory, file or stream. Free PDF Library for Delphi Developers - Quick PDF Library LITE. Search the site GO. Computer Science. Delphi Programming Basics Tutorials Database Applications. Print Computer Science. Delphi Programming Basics Tutorials Database Applications Advanced Delphi PHP Programming Language.
Using the above code,
Reader.ReadToEnd()
, I got no string, and coverb.pdf is empty.Delphi Print Pdf File
I'm using Delphi XE.
NGLN37.8k7 gold badges91 silver badges161 bronze badges
bagus prasojobagus prasojo
3 Answers
PDF files are generally compressed binary files and so cannot be read as UTF8. Doing so will lead to codec errors. Remember that not all sequences of bytes are valid UTF8 sequences.
It looks like you just need to call CopyFile instead of your complex stream based code, but perhaps this is just a cut down sample.
Freeware Print Pdf
David HeffernanDavid Heffernan534k35 gold badges876 silver badges1279 bronze badges
If the file is not empty but
Remy LebeauRemy LebeauReadToEnd()
is returning an empty string, then the TEncoding
object being used to decode the file bytes into Unicode is encountering conversion errors. The RTL does not raise an exception on string conversion errors. If all you want to do is make an exact copy of the file, use CopyFile()
, or use TFileStream
and the TStream.CopyFrom()
method.361k21 gold badges288 silver badges489 bronze badges
You can use Embarcadero's ReadAllText function. Like this:
Carolyna script font. Games by ubisoft. It will correctly detect ANSI, Unicode and binary files.
WeGoToMarsWeGoToMars10.4k14 gold badges118 silver badges232 bronze badges