Ask a Question related to Adobe Acrobat Macintosh, Design and Development.
-
Maurice_Leake@adobeforums.com #1
Printing programtically
I am trying to print from my plugin without throwing up the Print dialog, but it is not working. I am using the AVDocPrintPagesWithParams API call and it is consistently throwing a general exception with an error code of bad parameter. I am trying to print to my postscript printer and save the file has an image. This all works fine when I use the GUI, however it is not working via this automated method. I used the code from AVPrintSnip.cpp as a guide, and here is what I am doing:
AVDocPrintParamsRec r;
memset (&r, 0, sizeof(AVDocPrintParamsRec));
r.size = sizeof(AVDocPrintParamsRec);
r.pageSpec = PDAllPages;
// if true, displays dialog boxes; otherwise does not display
// dialog boxes.
r.interactive = false;
// If interactive is false and cancelDialog is true, a Cancel
// dialog box appears.
r.cancelDialog = false;
r.emitToPrinter = true; // only emitToPrinter or emitToFile must be true
r.emitToFile = false;
ASFileSys theFileSys;
ASInt32 retVal = AVAcquireSpecialFilePathName
(kAVSCUser,kAVSFDocuments,"test_print.pdf",
&theFileSys,&(r.filePathName));
// Used if emitToPrinter or emitToFile are true. First page
// to be printed; zero-based; if -1, then all pages are printed
r.firstPage = -1;
r.psLevel = 2;
r.binaryOK = false;
r.shrinkToFit = false;
r.doColorSeparations = false;
r.emitFileOption = kAVEmitFilePS;
r.emitFlags = 0;
r.emitFontOption = kAVEmitFontAllFonts;
r.ranges = NULL;
r.numRanges = 0;
r.reverse = false;
r.transparencyLevel = 3; //The transparency level range from 1 to 5
strcpy(&r.destProfile[0], "PostScript printing");
r.printAsImage = true;
ASPlatformPrinterSpecRec aspr;
memset(&aspr, 0, sizeof(ASPlatformPrinterSpecRec));
aspr.size = sizeof(ASPlatformPrinterSpecRec);
ASText prname = ASTextFromPDText("Adobe PDF 7.0");
ASUTF16Val* pval = &aspr.printerName[0];
&*pval = ASTextGetUnicodeCopy(prname, kUTF16BigEndian);
r.printerSpec = &aspr;
DURING
AVDocPrintPagesWithParams(avDoc, &r);
ASTextDestroy(prname);
ASFileSysReleasePath(NULL, r.filePathName);
r.filePathName = NULL;
HANDLER
ShowErrMsg(ERRORCODE);
ASTextDestroy(prname);
ASFileSysReleasePath(NULL, r.filePathName);
r.filePathName = NULL;
return(rcINTERNAL_ERROR);
END_HANDLER
Maurice_Leake@adobeforums.com Guest
-
CFGRID row highlight programtically
Can you programatically set a row to be highlighted in a CFGRID? I want to have the first row selected every time the form is loaded so as to... -
Freehand printing - right margin decreases when printing multiple copies of file.
I'm using Freehand mx. Everytime I print more than one copy of a file, the right margin decreases. Thus, if I print five or six copies of a file,... -
Printing Dynamically Insantiated MovieClips (multi-page printing)
I can create multiple pages with just one prompt with new PrinJob() object in Flash MX2004; but ... .... when I try to addpages which is one... -
Printing without showing the printing dialog window
hey - did you ever figure out a solution to the printing without dialog issue? i'm trying to get around the same problem myself. thanks! -jason -
Help: How can I find the error in a Procedure programtically
We have a procdure. Every night it will become invalid, but it will be recompiled automatically by our scripts. There is no bad influence on our... -
Maurice_Leake@adobeforums.com #2
Re: Printing programtically
I am having a hard time understanding how to populate the ASPlatformPrinterSpecRec under the MAC platform. The members are completely different than those of its Unix and Windows counterparts. I am particularly stuck on how to correctly populate printerName since it is defined as UniChar printerName[256]; and then theres the CGrafPtr--what the heck is this and what am I supposed to set it to. I have only been able to find a couple of threads on the Net and they are both related to Windows.
This is very frustrating--believe it or not, I've managed to get this far by examing the the header files (AVExpT.h and ASExpT.h) than with the documentation.
/* Define a platform specification for a printer */
#if MAC_PLATFORM
#define kPrinterSpecNameLen 256
typedef struct _t_ASPlatformPrinterSpec {
/** Size of the data structure. Must be set to
sizeof(ASPlatformPrinterSpecRec).
*/
ASSize_t size;
/** Port to print to. */
CGrafPtr *cGrafPtr;
/** Best known resolution of current printer. */
short hRes, vRes;
/** Name of printer. */
UniChar printerName[kPrinterSpecNameLen];
} ASPlatformPrinterSpecRec, *ASPlatformPrinterSpec;
#endif
Maurice_Leake@adobeforums.com Guest
-
Maurice_Leake@adobeforums.com #3
Re: Printing programtically
I've solved my problem! Here's what I learned if anyone is interested.
After pain-stakingly going over every inch of the AVDocPrintParamsRec structure in the AVExpT.h header file. I noticed the following comment for the filePathName member:
/* ... If emitToPrinter is true, and filePathName is non-NULL, then the system printer driver is used to emit the output stream to the file. This is implemented for Windows only. */
Please notice the reference to "Windows only". So, after starting all over from scratch and simply setting every parameter in the structure either to its default or the value that I wanted, and setting filePathName to NULL--it worked! The actual output file was written to my desktop; which isn't where I wanted it to be, but I can work around that.
So here's what I ended up with:
AVDocPrintParamsRec Parms;
memset (&Parms, 0, sizeof(AVDocPrintParamsRec));
Parms.size = sizeof(AVDocPrintParamsRec);
Parms.pageSpec = PDAllPages;
Parms.interactive = false;
Parms.cancelDialog = false;
Parms.embedded = false;
Parms.emitToPrinter = true;
Parms.emitToFile = false;
Parms.fileSysName = ASAtomNull;
Parms.filePathName = NULL;
Parms.firstPage = -1;
Parms.lastPage = -1;
Parms.psLevel = 3;
Parms.binaryOK = false;
Parms.shrinkToFit = true;
Parms.doColorSeparations = false;
Parms.emitFontOption = kAVEmitFontAllFonts;
Parms.ranges = NULL;
Parms.numRanges = 0;
Parms.reverse = false;
Parms.transparencyLevel = 0;
Parms.emitFileOption = false;
Parms.emitFlags = 0;
Parms.TTasT42 = true;
Parms.printAsImage = true;
Parms.printerHasFarEastFonts = false;
Parms.tileData = NULL;
Parms.rasterData = NULL;
Parms.overrideData = NULL;
Parms.selectRect = NULL;
Parms.ocContext = NULL;
Parms.resPolicy = kAVResPolicySendAtStart;
Parms.marksFlags = kAVCropMarks;
Parms.nUpData = NULL;
Parms.marksStyle = kAVDefaultMarkType;
Parms.printDialogWasCancelled = true;
Parms.parentWindow = NULL;
Thanks!
Maurice_Leake@adobeforums.com Guest
-
Tembowa@adobeforums.com #4
Re: Printing programtically
You may want to try asking these questions on the Acrobat SDK Forum where they actually ask programmatic questions. You will probably get a quicker response too.
~T
Tembowa@adobeforums.com Guest



Reply With Quote

