Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1586
  • Last Modified:

URGENT !!!!!! Embedding eps file into pdf

Hi everybody,

Am trying to embed an eps file into a pdf file.
When i try to load my pdf document it says, "file damaged.could not be repaired"

I want to solve this problem ASAP.Please help me in solving this issue.

Following is the pdf code :
---------------- CODE -----------------


1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R >>

2 0 obj
<< /Type /Outlines /Count 0 >>

3 0 obj
<< /Type /Pages
/Kids [6 0 R
/Count 1
/Resources <<
/ProcSet 4 0 R
/XObject << 
/PS1 8 0 R >>
/MediaBox [0.000 0.000 595.280 841.890]

4 0 obj
[/PDF /Text /ImageC ]

5 0 obj
/Creator (R and OS php pdf writer, http://www.ros.co.nz)
/CreationDate (D:20040903)

6 0 obj
<< /Type /Page
/Parent 3 0 R
/Contents 7 0 R

7 0 obj
<< /Length 39 >>
/PS1 Do

8 0 obj  <<
/Length 7989
/Type /XObject
/Subtype /PS

%!PS-Adobe-3.1 EPSF-3.0
%%Title: TextA.eps
%%Creator: Adobe Illustrator(R) X
%%AI8_CreatorVersion: 10.0%AI9_PrintingDataBegin%%For: LW
%%CreationDate: 9/3/2004
%%BoundingBox: 0 0 75 38


0 9
0000000000 65535 f
0000000015 00000 n
0000000080 00000 n
0000000126 00000 n
0000000283 00000 n
0000000320 00000 n
0000000425 00000 n
0000000488 00000 n
0000000599 00000 n

  << /Size 9
     /Root 1 0 R
     /Info 5 0 R

Awaiting your solution

Thanks in advance

  • 5
1 Solution
Karl Heinz KremerCommented:
The error message you quoted is usually caused by a corrupt xref table. It's impossible to verify the table with the data you've posted: PDF is a binary format, and when you embed it as a text file, it's no longer useful. Can you make this file available on the web somehow?

How are you embedding the EPS? And why?
Embedded PostScript is only supported by PostScript devices (e.g. a printer), and I doubt that it will work in e.g. Acrobat. The general recommendation is to not use embedded PostScript, because your otherwise platform independent PDF file will become platform dependent (e.g. it will only work on PostScript devices).

I see your EPS file was created by Illustrator, you can also export PDF from Illustrator and then bring this into your PDF file.

Also, without looking any deeper into your PDF file, I doubt that it would work (even with a PostScript printer) because you are not setting a transformation matrix before you place the EPS content.
Karl Heinz KremerCommented:
Here is information from the PDF Reference (v1.5, section 7.1):

"A PostScript XObject (Section 4.7.1, “PostScript XObjects”) contains a fragment
of code expressed in the PostScript page description language. PostScript XObjects
are no longer recommended to be used."

and from section 7.1.1:

"Note: Since PDF 1.4 encompasses all of the Adobe imaging model features of the
PostScript language, there is no longer any reason to use PostScript XObjects. This
feature is likely to be removed from PDF in a future version."

This chapter contains more information that advises against using PostScript XObjects.
Karl Heinz KremerCommented:
OK, I took your file and saved it as a text file, then I used a tool that prints the byte offset for every line and fixed the xref table. One thing that is definitely wrong is your offset to the xref table (startxref): 2226 is definitely wrong if object 8 is at offset 599.

You should use other tools than Acrobat (or Reader) to debug your PDF files. xpdf for example gives much more useful error messages (as does Ghostscript). Once I had the xref table fixed, I got the following error message from xpdf:

Error (577): Missing 'endstream'
Error: Missing 'endstream'
Error (555): Unknown operator 'endstream'
Error (557): Unknown operator 'endobj'
Error (572): Unknown operator 'obj'
Error: Missing 'endstream'
Error: Leftover args in content stream

As you can see, you get a byte offset, and the associated error. It looks like something is wrong with the PS stream that you've embedded.  

Here is the error message reported by Ghostscript:

gs ./test.pdf
ESP Ghostscript 7.07 (2003-07-12)
Copyright 2003 artofcode LLC and Easy Software Products, all rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
Processing pages 1 through 1.
Page 1
Error: /syntaxerror in stream
Operand stack:
   --dict:3/3(L)--   1072   7   0   --dict:3/3(L)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1057/1417(ro)(G)--   --dict:0/20(G)--   --dict:73/200(L)--   --dict:73/200(L)--   --dict:97/127(ro)(G)--   --dict:229/230(ro)(G)--   --dict:19/24(L)--   --dict:4/6(L)--   --dict:19/20(L)--
Current allocation mode is local
ESP Ghostscript 7.07.1: Unrecoverable error, exit code 1

The most important part is right at the beginning: syntax error in stream.

Karl Heinz KremerCommented:
I suspect hat you removed information from the file (e.g. the actual EPS content). The content length of the EPS stream does however still not match the startxref information. I was able to open the file by changing the two stream lengths (the page content and the PS xobject) to respectively 8 and 126

It's important that you understand what the Length entry in the stream object is. The PDF Reference contains the definition. It's the length of the actual stream (regardless of any compression applied, so for uncompressed data it's the length of the uncompressed data, and for compressed data it's the length of the _COMPRESSED_ data). It's the number of bytes from the first character of the line following the "stream" keyword until the last byte before the "endstream" keyword (including any line terminators).

It's usually best to but "Length" information into a separate object that you reference from the stream object, but write out after the stream object. This way, you can just take the locations in the file reported by seek() and subtract them (minus 1).  
Karl Heinz KremerCommented:
Any luck?

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now