hi everyone...
I am very new to PDF programming
basically I wrote my program in notepad and I saved it as .pdf format
but when I open it and try to close it..it showing me pop up like do you want to save changes..which is I dont want to happen...
is any one have idea what changes i have to do or how i make my file readonly....
thnks in advance...
Jay,
take a look at my comments I provided in this question yesterday:
http://forums.adobe.com/thread/998312?tstart=0
You are running into the same problems. PDF is a binary file format, and
your byte offsets in the cross reference table are incorrect. Acrobat will
repair your file for you when you load it, and because at the time you want
to close the file, it's different than the one you have on disk (it
contains Acrobat's fixes), the application is prompting you to save it.
Once your byte offsets are correct, this will no longer happen.
Karl Heinz Kremer
PDF Acrobatics Without a Net
thanks Irosenth,
Well my requirement is very small.....
I am not using many XObjects In my program except one which is for Image
ok Following code , I copied from PDF refe tutorials. Even that is also not working(Asking me for Save before close).. can anyone correct xref to avoid that error
%PDF-1.4
1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<< /Type /Outlines
/Count 0
>>
endobj
3 0 obj
<< /Type /Pages
/Kids [4 0 R]
/Count 1
>>
endobj
4 0 obj
<< /Type /Page
/Parent 3 0 R
/MediaBox [0 0 612 1000]
/Contents 5 0 R
/Resources << /ProcSet 6 0 R >>
>>
endobj
5 0 obj
<< /Length 883 >>
stream
% Draw a black line segment, using the default line width.
150 250 m
150 350 l
S
% Draw a thicker, dashed line segment.
4 w% Set line width to 4 points
[4 6] 0 d% Set dash pattern to 4 units on, 6 units off
150 250 m
400 250 l
S
[] 0 d% Reset dash pattern to a solid line
1 w % Reset line width to 1 unit
% Draw a rectangle with a 1-unit red border, filled with light blue.
1.0 0.0 0.0 RG% Red for stroke color
0.5 0.75 1.0 rg% Light blue for fill color
200 300 50 75 re
B
% Draw a curve filled with gray and with a colored border.
0.5 0.1 0.2 RG
0.7 g
300 300 m
300 400 400 400 400 300 c
b
endstream
endobj
6 0 obj
[/PDF]
endobj
xref
0 7
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000120 00000 n
0000000179 00000 n
0000000300 00000 n
0000001532 00000 n
trailer
<< /Size 7
/Root 1 0 R
>>
startxref
1556a
%%EOF
xref
5 1
0000000179 00000 n
trailer
<<
/Root 1 0 R
>>
thanks in advance.
Let's approach this from a different angle: Why are you trying to generate
a PDF file manually? Creating a PDF file this way is almost always a
pre-cursor to writing software to output PDF. It does not make any sense
for an end user to create a PDF based on the PDF spec. That's why we have
software that does that. Even if you need a PDF file with a specific
feature, there is usually no need to hand craft a file: You can just write
a PostScript file (which is a text format, and can be written based on the
PostScript spec) and then run it through a PSToPDF converter like
Distiller.
So again, why do you think you need to write a PDF file in a text editor?
Karl Heinz Kremer
PDF Acrobatics Without a Net
Thanks Karl,
Your question is on target, am very thankfull for that
ok, the thing is we are working on HTML 5 project where client
take print out of web page
so, direct print out of web page will not come properly
thats why We are planning to write PDF programming and integrate in HTML.
I knw their are many tools but they are coslty and will keep unneccessary burden on Finance team
our need is not much
we already acheieved what we want ..and just get stuck on Xref ..
and looking for solution of that
Jay,
I don't quite understand what you want to accomplish, but it sounds like
some level of HTML to PDF conversion. Yes, there are existing solutions,
and they may seem to be expensive, but based on my own experience, they are
worth what you pay for (and more). It may seem that building your own
solutions could be cheaper, but again, based on my own experience, you will
waste a lot of time and money to come up with something that works as well
as anything that you can buy today.
Based on your problems coming up with a correct XRef table, it looks like
you do not have a deep enough understanding of the PDF spec to do this.
I've read the spec too often to count. It's not an easy to read document,
but you need to read and understand every part of it. There is no way
around it.
I work mostly on software that processes existing PDFs, and almost every
PDF file that is generated by somebody who thought that they needed to
re-invent the wheel and write their own PDF generator, they end up writing
corrupt PDF. Go with one of the established solutions, it will pay for
itself in the long run.
If you really want to write PDF in an editor, you need an editor that shows
you byte offsets. I use vim in it's binary mode.
Karl Heinz Kremer
PDF Acrobatics Without a Net
Hi Karl,
I am sorry for I failed to Draft my question properly
but thank god ..at the end you get me right..
yes,I agree My knowledge is not upto the mark to write PDF programs(bcoz I m jst reading PDFReference documentation frm last 2 weeks only)
And yes, Its realated to HTML2PDF Conversion kind of.
Well, I am thankful of you.
now I dont have a single question..your last post cleared my all doubts and
thanks to show me right way and saveing my time.
God Bless you.
Hi at all
First of all, sorry for my bad english. Im a german. But i do my best :-)
I'm working on a project. There i have to search for a possibility to creat pdf's on WinCE. The problem is, therfore are no pdf creater available. So i have chosen to do it on myself. I write it with notepad and a hex-editor. I created a pdf that contains only text. My problem now is the xref table, the stream length works fine. I got the same problem as the Thread opener. Adobe corrects my file and so wants to save it. But i cant find any failure in my xref table. I built it with the hex-editor. I opened the file there and then selected the first number of every object, read the Byte-Number and wrote it in the xref table.
Here is my pdf: http://www.file-upload.net/download-7065580/TestdateiForWWW.pdf.html
I would be very thanksful if you can help me. I don't have any idea what i do wrong.
Welcome to a long journey.
I have to say that writing in this way is a dead end; everyone eventually (soon) has to write software to generate the PDF, and it is better to start sooner rather than later, in my opinion.
Ok... I like to answer questions with questions.
1. What do the characters in the Info dictionary represent?
2. What do you understand the line "0 10" to exactly mean in the xref?
3. What do you understand the /Size 10 to exactly mean in the trailer?
Well i know, i dont have the best way to create a pdf document. But i only need it to display text and i need it as quickly as possible.
But thanks for your fast answer!
1) Ok, i have to say i copied this. In my opinion it isnt really important for validating the pdf. I thought i look at this when my pdf is valid. This are meta datas that document some data about the creation of the file.
2) Its the number of indirect objects in the pdf document. I thought i am right with 10. But after your question i see i forgot the not existing object 0, right? But you asked for exactly... "0" represents the numer of the first indirect object in the document and "10" represents the number of indirect objects in the document.
3) This size represents the same as the "10" in the xref. It's the number of indirect objects. Here i missed the indirect object 0 too, i think.
Many thanks for your help!!!
EDIT: Ok, that helped out for the problem that adobe want to correct my file. But when printing there still is a message that my file is corrupted. Occurs this cause of my info dictionary?
1) What you are putting in is basically junk; the dates must follow particular formats, and will be readable text; and the other things should (at the basic level) be regular ASCII text. It's important to get Producer or Creator right at the earliest opportunity, because it identifies your software which made the file. In Adobe Reader or Acrobat, File > Properties will show these. In fact a "modern" PDF should use XML metadata instead of an Info dictionary.
2,3) These didn't look right to me, so try that. I see the "10" in xref as "number of lines following", rather than "number of objects" even if these are closely related.
Thanks for your answers!
@ Screen Name:
1) Ok, your right. I corrected it.
2) Ok, you probably are right. But in my cases it always was the same.
@Irosneth
Thanks for the documents. I will study the ISo-document. But mostly it dont describe the failures, so it isnt very helpful because then you have to check the whole document.... I think to buy a bok is a little oversized for me. I only want to show text in the simplest form it is possible.
Nobody can stop you doing that, and it may even work for your own project, but I really wish you wouldn't distribute a file as a model for people who "don't want to learn PDF, nor buy or write software". I think it will cause them no end of issues. I write as someone who's spent the last 15 years seeing the kinds of deep water PDF beginners get in to.
PDF NEEDS TO BE WRITTEN BY SOFTWARE. Good software. Really.
Hm..ok, if you show me a good pdf-creator for winCE, i will use it. But i spent a day on searching for such a pdf creatorand there is no one.
I try to explain you my problem. In my company we produce machines. They produce statistics about that they do. Now i want to save these statistics in a pdf-file. But there is no pdf-creator, so we have to write one for our use. And i am a student and dont cost much, so i have this damn job to write such a pdf creator. And becaouse of we have many different machines, it should be as easy as it could be to adapt the file from the old machine to the statistics from the other machine. And i cant do this for the whole company, so the others must be able to adapt it too.
I hope you can understand it.
I thought I would mention some additional problems. Acrobat X doesn't complain about them, but they are invalid and any software will potentially complain or fail.
1. Missing Widths in font descriptor. It is surprising that this got past. I'd recommend that if you want a simple sans serif font that you use the Helvetica and Helvetica-Bold standard fonts. Or for any other font good practice is to embed it. Arial is not a "magic" font which is guaranteed to be available.
2. Acrobat preflight rejects the file. Probably this is because of the last piece of the content stream
BT
29 746 m 595 746 l 3 w s
30 713 m 595 713 l 0.7 w s
30 581 m 595 581 l 0.7 w s
30 559 m 595 559 l 0.7 w s
30 426 m 595 426 l 0.7 w s
30 34 m 595 34 l 3 w s
ET
These line drawing operators are not valid in a text object. However, even fixing this fails some preflights. I believe it violates more restrictions in table 9 (section 8.2).
3. You inherit Resources and MediaBox. This is of course permitted, but it does cause a number of real world problems so it is best avoided. To streamline the file Resources can point to the same indirect object.
North America
Europe, Middle East and Africa
Asia Pacific