Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDFWriter and logo.pdf on every page

Status
Not open for further replies.

Up2

Technical User
May 12, 2004
6
DK
I'm using RedMon and Postscript (PDFwriter) to create PDF files.
I'm writing A4 reports from within a Windows program.
I write to PDF instead of PS to make use of the fonts, and haven't had any luck with getting the PS output to be in a proper quality. Despite that my logo file is also PDF.

When I write the PDF file, I want a logo.pdf file to merge/overlay together with the PDF output. But I can't get this to work with the PDFwriter.

Isn't this possible with Postscript?

Beware, I'm not much of a PS code shark :)
 
It is possible, but would be extremely difficult.

PostScript doesn't supply any filter or native processing of PDF files.

But, it can read files a byte (even a bit) at a time. So, it is theoretically possible for a PostScript program to read a PDF file and extract the content stream, image data, text, etc. But it would be a pretty tedious job!

Page 22 of the official PDF Reference 1.4 describes the approach:

Because of these differences, a PDF file generally cannot be transmitted directly to a PostScript output device for printing (although a few such devices do also support PDF directly). An application printing a PDF document to a PostScript device must carry out the following steps:

1. Insert procedure sets containing PostScript procedure definitions to implement the PDF operators.

2. Extract the content for each page. Each content stream is essentially the script portion of a traditional PostScript program using very specific procedures, such as m for moveto and l for lineto.

3. Decode compressed text, graphics, and image data as necessary. The compression filters used in PDF are compatible with those used in PostScript; they may or may not be supported, depending on the LanguageLevel of the target output device.

4. Insert any needed resources, such as fonts, into the PostScript file. These can be either the original fonts themselves or suitable substitute fonts based on the font metrics in the PDF file. Fonts may need to be converted to a format that the PostScript interpreter recognizes, such as Type 1 or Type 42.

5. Put the information in the correct order. The result is a traditional PostScript program that fully represents the visual aspects of the document but no longer contains PDF elements such as hypertext links, annotations, and bookmarks.

6. Transmit the PostScript program to the output device.


Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Ok, thanks for your answer tgeer.

I have tried to use the bugs.ghostscript.com to ask this question. The bugnr. is: 687424.
RedMon transfers data to Ghostscript through the standard input. So the command
line must end with "-" and cannot contain "-c quit". So you need to disable
or delete "showpage" from your logo file and run it from the /BeginPage procedure.
For instance:

File beginpage.ps
%!
<< /BeginPage [
% duplicate the operand
{ dup } bind aload pop

% get the old BeginPage
currentpagedevice /BeginPage get aload pop

% append our procedure
{ 1 and 0 eq % every other page
{
/save_state save def
/showpage {} def
(logo.ps) run
save_state restore
}
if
} bind aload pop
] cvx
>> setpagedevice

File logo.ps
%!
gsave
clippath pathbbox { -72 -72 36 36 } { add 4 1 roll } forall
4 copy rectstroke
4 2 roll translate
0 0 moveto
2 copy lineto
0 exch moveto
0 lineto
stroke
grestore
showpage

Sample command line.
cat foo.ps | gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=foo.pdf -c .setpdfwrite -f beginpage.ps -


It seems that there might be a little possibility that it could be done, but I didn't get it to work :S

So I'll believe your conclusion...

But where does that leave me. :)
I can use ghostscript to output in PDF. But do you know of a program that can merge two files together, from the commandline?

 
Two files of what type, PostScript, or PDF?

And when you say merge, do you mean, combine drawing instructions from two programs onto ONE page?



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
I use GS to output in PDF, using the PDFwriter. This is the only way I could get my text to appear clear and not all pixelated and ugly.

So now I have my output.pdf - which is written from my application (A Windows Economy app.)

I always have the same logo.pdf file. That would I like to insert onto the output.pdf file (merge onto EVERY page). Like a watermark, but not greyed out or with some kind of transparency.

I will try to explain myself using and ascii example :)
Here goes:

|------|
|out | output.pdf
|------|

|------|
| * | logo.pdf
|------|

|------|
|out *| final.pdf
|------|

As you see on the final.pdf it contains both the text/grapichs from output.pdf and from logo.pdf.
 
I can tell you how to do that with PostScript. If there is a way to do that with PDF files, I don't know it.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Fair enough.
Can my output be as nice with postscript as pdf (using the pdfwriter)? -I'm only printing text(times,arial,courier,verdana).

On my testsetup I had some problems with my text beeing formattet as bitmap and not text. That looked kinda blurry, and was the reason why I tried the pdfwriter.

Still I have my logo as PDF. Is it easy to convert it to PS or eps and use it?

If you see a way to create a solution using PS, I would very much like to hear it.

And thx for your help so far - appreciate your time.
 
PDF is based on the PostScript imaging model. Ideally, PostScript language programs shouldn't contain any device-dependent (and thus "quality" specific) code. Everything is vector, and the device outputs it at whatever quality it can support.

You may have to deal with image data, but you can control the resolution within PostScript.

There are a TON of posts from me and others in this forum about how to include images or EPS in PostScript.

Search the forum for "form" and "EPS" keywords. If you want to place the form (logo) on every page, you can use the /BeginPage pagedevice dictionary. That's documented in posts here, too.

It is easy to translate PDF to EPS. Many different programs can do this, including Acrobat, Illustrator, Photoshop. I think GhostScript can do it, too. I don't know, I don't use GS.

Font problems aren't the fault of your PostScript, it's the fault of whatever is interpreting/rendering your PostScript.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Ok, what other alternatives do I have if I want to create a windows printer that can output vector PS files. This should happen without the user has to do anything else than to push "print", like to an ordinary printer.

I have only tried this with ghostscript, but it seems that it's a bit buggy on the vector text part...
 
What language are you programming in? There is a post here somewhere that describes how to create a windows printer port that points to a file. That way there are no "print dialog boxes" i.e. silent printing. You might search the forum for "silent printing" or "port".

The idea is with a windows language such as VB you could direct an application to print to this port, then open a manipulate the resulting PostScript file (strip out the PJL commands, add your logo and/or form dictionaries, etc) then pass the file to Distiller (or GhostScript, whatever).


Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
I'm printing from a normal windows program. And not programming anything. Except something called XAL, which can use DLL connection.

BUT I don't know how to code PS or VB. I'm just a superuser and programmer in XAL.

I have found a way to pass to GhostScript, but i get my fonts out as bitmaps.

Is Distiller a freeware program that can do the same as Ghostscript (handle the print output)?

So basically I need a program that can handle the output the way I want and in the end make me end up with a PDF.

With other words - I'm a NOOB :)
 
Distiller is not freeware. You get it as part of the complete Adobe Acrobat 6.0 Standard or Professional package.

You get what you pay for.

That said, I know that GhostScript supports fonts as fonts. I would suggest that you explore that as the main/first challenge. I don't "know" GhostScript... I explored it awhile ago and it had some issues with what I knew was "good" code, so I use commercial products with dedicated tech support for my toolset.

If you have usenet/newsgroup access, the comp.lang.postscript is essentially all about GhostScript. My suggestion to you is to post a message there titled "GhostScript font rendering problem", and provide as much detail as possible: What OS, version of GhostScript, font name(s) and vendors, command lines you're using, how you're viewing the results, links to the PDF files for inspection, etc.

Then, once you have the GhostScript issue figured out, come back here for the EPS/image embedding/merging questions!



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top