Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / August 2005



Tip: Looking for answers? Try searching our database.

CMYK and PDF with CFDOCUMENT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VillageX - 15 Aug 2005 15:57 GMT
I need to produce a "print quality" PDF file using CFDOCUMENT.  By "print
quality" I mean a file that can be taken straight to press by a commercial
printer.  The problem I am having is as follows:

The PDF contains only text.  The text is dynamically generated; and I'm using
inline CSS styles to control the color of the font.

The printer tells me that they need the color setup in "CMYK".

When they open it in Photoshop, they get CMYK channels for the text; but it
uses all four channels, not just the black.  They want it just using the black
channel (The text is black), so that it is a "one color" job, as opposed to a
"four color" job.

We tried converting a CMYK color to RGB, and inputting that value for the
black text.  However, when it is loaded into the PDF, it then translates to a
different CMYK value (a four-color one) than we set.

Is there something I am missing?  Is there a way to force the PDF to use the
correct CMYK value for the font color?
Marc E - 15 Aug 2005 23:33 GMT
i'm not sure if you'll be able to do this with cfdocument...i highly doubt
it. getting vendors to provide cmyk support is really tough if that vendor
isn't in the print market.

you might be able to simply optimize the pdfs before sending to the printer.
you can set "joboptions" for the optimization that should be able to do what
you need. I'm no optimization expert, so i probably won't be able to answer
any questions about it, but i know that optimization is how a lot of
companies get around this sort of thing.

good luck.

>I need to produce a "print quality" PDF file using CFDOCUMENT.  By "print
> quality" I mean a file that can be taken straight to press by a commercial
[quoted text clipped - 22 lines]
> the
> correct CMYK value for the font color?
iborsb - 16 Aug 2005 14:11 GMT
Hi

Im having the same issue - I need to produce a CMYK pdf for print output. If
cfdocument isnt the answer then can anyone suggest another piece of software/
extension I could use in its place?

I also need to be able to set the pdf to be 300 dpi. Other comments in this
forum suggest that the .pdf file is automatically set to be 96 dpi for screen
output.

My other thought was that I could create a .tiff file using cffile to create a
document that could be used for print?

Has anyone else had an issue with creating printable documents straight from
the web?
BKBK - 17 Aug 2005 12:10 GMT
>... spike's relative path trick.
Goodie! Cheers.
VillageX - 19 Aug 2005 15:10 GMT
Thanks to all for the suggestions.  My client has discovered that they don't
actually need the CMYK problem solved in this particular case, because they
have another software package in their process that can do the conversion.  I
have a feeling this will come up again though, so I'm going to check out the
other suggestions here.  In particular, I'm also interested in the DPI thing.

Does anyone know if there is any possibility that a future release of CF will
include more options with PDF creation through CFDOCUMENT?
iborsb - 19 Aug 2005 17:00 GMT
Hi I think i'll take Paulh's advice and use the iText software.

Still havent had anyone confirm what the DPI and RGB setting is for
cfdocument. If my starting document is a CMYK tif set at 300dpi and then I want
to overwrite some dynamic text to that file would I still expect that my image
would revert to 96dpi and rgb.  I'm presuming this is the case though.

Thanks for the help
Marc E - 22 Aug 2005 19:01 GMT
i don't know if that's what will happen...PDFs, unless they're "image" pdfs,
are like postscript files in that they don't really have a single
resolution. they can have any number of blocks with any number of
resolutions.

i use a program called pdfspy by apago software to do pdf analysis, and the
results of an inspection really bear this out. we wanted to see if we could
programatically determine pdf resolution, but in the end it's nearly
impossible to do so and get any meaningful results. you might scan for the
lowest resolution block, but what if that 96 dpi block that the program
found is a usless piece of white or something? these are the questions we
couldn't find a way around and so just gave up on. the problem with pdf,
unlike EPS, is that you can have so many different embedded types (line-art
text, raster tif files embedded, etc), whereas with EPS you can create a
document that is resolution-less but which will scale regardless since under
the hood it's all just math.

i think in your sample here starting with a tiff file and writing text on
it, then just get CF out of the picture entirely. use itext or pdflib,
because it's so easy to do so nowadays. you could create a pdf document,
import the tiff, write the text, and close the doucment in probably 10-20
lines of code with itext or pdflib, and it's going to be fast (pdflib flies)
and to your specifications.

marc

> Hi I think i'll take Paulh's advice and use the iText software.
>
[quoted text clipped - 6 lines]
>
> Thanks for the help
iborsb - 30 Aug 2005 15:11 GMT
I'm finally getting somewhere with this - i've written the following code -
which creates my pdf.

Whats the best way for me to get the text into the correct position?

Also, when I add the paragraphs it automatically drops the second line down
despite the use of the new page item.

Any ideas?

<cfscript>
// create a 'Document' object
rectangle = CreateObject("java", "com.lowagie.text.Rectangle");
pageSize = Rectangle.init(240, 155);
Font = CreateObject("java", "com.lowagie.text.Font");
FontFactory = CreateObject("java", "com.lowagie.text.FontFactory");
Chunk = CreateObject("java", "com.lowagie.text.Chunk");
Element =  CreateObject("java", "com.lowagie.text.Element");

CMYK = CreateObject("java", "com.lowagie.text.pdf.CMYKColor");
document = CreateObject("java", "com.lowagie.text.Document").init(pageSize, 0,
0, 0, 0);
Image = CreateObject("java", "com.lowagie.text.Image");

font1 = FontFactory.getFont(FontFactory.HELVETICA);
 
// get an outputstream for the PDF Writer
fileIO = CreateObject("java", "java.io.FileOutputStream");
// call the constructor, pass the location where you want
// the pdf to be created
fileIO.init("#expandpath("test2.pdf")#");
// get a PDF Writer var
writer = CreateObject("java", "com.lowagie.text.pdf.PdfWriter");
// call the static 'getInstance' factory method
writer.getInstance(document, fileIO);
// open the document
document.open();
// create a new paragraph
paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
phrase = CreateObject("java", "com.lowagie.text.Phrase");

phrase0 = paragraph.init(" ", Font.init(Font.HELVETICA, 5));

phrase = paragraph.init("Name : #url.name#", Font.init(Font.HELVETICA, 5));
phrase.setAlignment(Element.ALIGN_CENTER);

phrase2 = paragraph.init("JobTitle : #url.jobtitle#",
Font.init(Font.HELVETICA, 5));
phrase2.setAlignment(Element.ALIGN_CENTER);

phrase3 = paragraph.init("Clubname : #url.clubname#",
Font.init(Font.HELVETICA, 5));
phrase3.setAlignment(Element.ALIGN_CENTER);

phrase4 = paragraph.init("Address 1 : #url.address1#",
Font.init(Font.HELVETICA, 5));
phrase4.setAlignment(Element.ALIGN_CENTER);

phrase5 = paragraph.init("Address 2 :#url.address2#",
Font.init(Font.HELVETICA, 5));
phrase5.setAlignment(Element.ALIGN_CENTER);

phrase6 = paragraph.init("Address 3 : #url.postcode#",
Font.init(Font.HELVETICA, 5));
phrase6.setAlignment(Element.ALIGN_CENTER);

phrase7 = paragraph.init("T : #url.telephone#", Font.init(Font.HELVETICA, 5));
phrase7.setAlignment(Element.ALIGN_CENTER);

phrase8 = paragraph.init("F : #url.fax#", Font.init(Font.HELVETICA, 5));
phrase8.setAlignment(Element.ALIGN_CENTER);

phrase9 = paragraph.init("E : #url.email#", Font.init(Font.HELVETICA, 5));
phrase9.setAlignment(Element.ALIGN_CENTER);

//add the image
png = Image.getInstance("#expandpath("businesscardside1.png")#");
png.scalePercent(24, 23.845);
png.setDpi(300,300);
png.setAlignment(Image.UNDERLYING);

document.add(png);
document.add(phrase0);
document.add(phrase0);
document.add(phrase0);
document.add(phrase);
document.add(phrase2);
document.add(phrase3);
document.add(phrase4);
document.add(phrase5);
document.add(phrase6);
document.add(phrase7);
document.add(phrase8);
document.add(phrase9);

document.newPage();
png1 = Image.getInstance("#expandpath("businesscardside2.png")#");
png1.setDpi(300,300);
png1.setAlignment(Image.UNDERLYING);
png1.scalePercent(24, 23.845);
document.add(png1);

// close the document (PDF Writer is listening and will automatically
// create the PDF for us
document.close();
</cfscript>
PaulH - 30 Aug 2005 20:57 GMT
there's a boatload of methods to finesse paragraphs like setSpacingBefore(),
setIndentationLeft(), etc. or you could move everything into a pdfTable &
fiddle with the cells. itext has an insane amount of control you can apply
(sort of a curse as well as a blessing). your best resource for itext is bruno
and paulo on the list:
itext-questions@lists.sourceforge.net
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.