473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to copy binary data

Greetings;

I'm a (young) .NET developer and I have this problem: I'm building an
application (with C#) that creates PDF files. To display a JPEG image within
the PDF I need to copy the data from the JPEG file to the PDF (intended as a
text file); I've tryied with the FileStream class, but it won't work, maybe
bacause, somehow, the binary data "changed" during the read/write process.

Is there any method to copy the data without changing it?

Thank you very much in advance
Nov 16 '05 #1
5 8017
Alex,

Pdf are always difficult questions in this newsgroup. Did you already try it
ad Adobe.
When you know the basics, than it is mostly easy with C#.

Cor
Nov 16 '05 #2
Hi Alex,

Nothing changes the data in the FileStream unless you write to the stream.
There are methods in Framework 2 that will return all data in a file
without using the FileStream (although internally they may still use it),
like File.GetAllBytes etc, but I suspect the problem is in your code, not
in the FileStream.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
For this types of questions, my advice to you is try comp.text.pdf.

Knowing how to embed an image XObject into a PDF file requires that you have
significant knowledge on the PDF file format.
JPEG is special, this is the only format which can be directly embedded into
a PDF file, using DCT encoding.
Your XObject should look *something* like:
<</Type/XObject/Subtype/Image/Name/X16
/Width X
/Height X
/ColorSpace/DeviceRGB/Filter/DCTDecode/BitsPerComponent X
/Length X
/Decode[0.0 1.0 0.0 1.0 0.0 1.0]
stream
[BINARY IMAGE STREAM]
endstream
endobj

You will have to declare usage of images in the ResourceDict->ProcSet
attribute,
it should look like this:
/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"AlexCDM" <Al*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com... Greetings;

I'm a (young) .NET developer and I have this problem: I'm building an
application (with C#) that creates PDF files. To display a JPEG image
within
the PDF I need to copy the data from the JPEG file to the PDF (intended as
a
text file); I've tryied with the FileStream class, but it won't work,
maybe
bacause, somehow, the binary data "changed" during the read/write process.

Is there any method to copy the data without changing it?

Thank you very much in advance

Nov 16 '05 #4
Dennis,

Where can I get the specification of the PDF file format?

Thanks,
Duy

"Dennis Myrén" <de****@oslokb.no> wrote in message
news:u1***************@TK2MSFTNGP14.phx.gbl...
For this types of questions, my advice to you is try comp.text.pdf.

Knowing how to embed an image XObject into a PDF file requires that you
have
significant knowledge on the PDF file format.
JPEG is special, this is the only format which can be directly embedded
into
a PDF file, using DCT encoding.
Your XObject should look *something* like:
<</Type/XObject/Subtype/Image/Name/X16
/Width X
/Height X
/ColorSpace/DeviceRGB/Filter/DCTDecode/BitsPerComponent X
/Length X
/Decode[0.0 1.0 0.0 1.0 0.0 1.0]
stream

[BINARY IMAGE STREAM]
endstream
endobj

You will have to declare usage of images in the ResourceDict->ProcSet
attribute,
it should look like this:
/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"AlexCDM" <Al*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
Greetings;

I'm a (young) .NET developer and I have this problem: I'm building an
application (with C#) that creates PDF files. To display a JPEG image
within
the PDF I need to copy the data from the JPEG file to the PDF (intended
as a
text file); I've tryied with the FileStream class, but it won't work,
maybe
bacause, somehow, the binary data "changed" during the read/write
process.

Is there any method to copy the data without changing it?

Thank you very much in advance


Nov 16 '05 #5
Thank you all for the answers, I'll work on it.

(Dinh Duy Tran, I've found the pdf reference here

http://partners.adobe.com/public/dev...reference.html

)
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Apricot | last post by:
#include <iostream> #include <string> #include <map> using namespace std ; class tst { public : tst() { cout << "tst::constructor" << endl ; } tst(const tst & that) { cout << "tst::copy...
6
by: Karl Ebener | last post by:
Hi! I am currently using a string to hold data (can be strings as well as binary!). Now it occured to me, that the <string> might be unable to handle Null-Bytes. Is that so? Following...
2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
9
by: David Rysdam | last post by:
I have a large amount of data that I copy in and out of Sybase very often. Now I also want to copy this data in and out of postgres. I have an existing script that creates the entire database(s)...
0
by: NetronProject | last post by:
My copy/paste operation results in a MemoryStream full of '\0' characters on the Clipboard. Maybe my approach to copy/paste is wrong when handling generic types. All entries in the CollectionBase...
4
by: Kyote | last post by:
I'm trying to persist a list of filenames. I've made a custom collection and a FileName class: 'Class to hold file name information Public Class FileNames Public fullName As String Public...
1
by: nordy | last post by:
Hi, I have these tables with binary data stored in tinyblobs and blobs in MySql. In my application I sometimes need to copy them to another table. Not all the data, maybe just a column or two. So...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.