Skip to main content
Participant
March 14, 2006
Question

IndesingCS2 server scriptable pluign: how to import image file into a frame.?

  • March 14, 2006
  • 12 replies
  • 1445 views
Hello<br />I am creating a scriptable pluign for indesingcs2 server.<br />Now I am stuck at importing a image file in a image frame on a document.<br />The code which was running fine for indesingcs2 desktop is given below.<br />//////////////////////////////////////////////////////////////////////////////////////////////////<br /> IDFile sysFile = SDKUtilities::PMStringToSysFile(const_cast<PMString* >(&ImageFileNamewithcompletepath)); <br /> InterfacePtr<ICommand> importCmd(CmdUtils::CreateCommand(kImportAndLoadPlaceGunCmdBoss));<br /> if(!importCmd) <br /> return kFalse; <br />InterfacePtr<IImportFileCmdData> importFileCmdData(importCmd, IID_IIMPORTFILECMDDATA); <br /> if(!importFileCmdData)<br /> return kFalse;<br /><br /> <br /><br /> //db is input.I got it using the techniques mentioned in the indesign-server-plugin-techniques.pdf<br /> //page 18..<br /> importFileCmdData->Set(db, sysFile, kMinimalUI);<br /> ErrorCode err = CmdUtils::ProcessCommand(importCmd);<br /> if(err != kSuccess) <br /> return kFalse;<br /><br /> InterfacePtr<IPlaceGun> placeGun(db, db->GetRootUID(), UseDefaultIID());<br /> if(!placeGun)<br /> return kFalse;<br /><br /> <br /> UIDRef placedItem(db, placeGun->GetItemUID());<br /><br /> InterfacePtr<ICommand> replaceCmd(CmdUtils::CreateCommand(kReplaceCmdBoss));<br /> if (replaceCmd == nil)<br /> return kFalse;<br /><br /> InterfacePtr<IReplaceCmdData>iRepData(replaceCmd, IID_IREPLACECMDDATA);<br /> if(!iRepData)<br /> return kFalse;<br /> <br /> iRepData->Set(db, imageBox.GetUID(), placedItem.GetUID(), kFalse);<br /><br /> ErrorCode status = CmdUtils::ProcessCommand(replaceCmd);<br /> if(status==kFailure)<br /> return kFalse;<br /><br /> return kTrue;<br />/////////////////////////////////////////////////////////////////////////////////////////////////<br />I used the same code for making scriptable plugin for indesignCS2 server as it doesn't involve use of any UI element.<br />But this code is not working.It doesn't crash or returns kFalse.<br />What i see after executing the plugin through script is a grey region for image in the graphics frame.<br /><br />I request if anyone gives me solution to this i will be highly grateful to him.<br /><br />Thanks and Regards,<br />Yogesh Joshi
This topic has been closed for replies.

12 replies

Participant
March 19, 2007
Hi friend,

Do anyone has the solution of same problem :( with javascript. I am facing the same but i am doing the developement in javascript.

I would be heartly greatful for any help..

Thanks & Regards

Vikas
pardalek
Inspiring
January 9, 2007
Ok I have solved it. The problem wasn't in the server settings but in the SnapshotUtils initialization. You get no gray rectangles in the exported jpegs if you set right these parameters in SnapshotUtils


int32 flags = IShape::kPreviewMode|IShape::kPrinting,
bool8 fullResolutionGraphics = kFalse,
bool8 drawGray = kFalse,
bool8 addTransparencyAlpha = kFalse,
Transparencies transparencyQuality = kXPHigh,
const PMReal & greekBelowPtSize = 7.0,
bool8 antiAliasing = kTrue


:)

Pardál
pardalek
Inspiring
January 9, 2007
I have simillar problem - I can't find the right place where to allow imagePreviews. The difference is that I am getting the contents of the frames by importing an xml file into the document (which also loads the proper pictures). Jpegs are always gray on export. I put the IServerSettings bit right before the ProcessCommand(importXMLCmd), but this doesn't help :( I also tried to change the server properties by JavaScript. Again, no luck.

Does anyone know how to make the images visible for exported jpegs which are loaded through the kImportXMLFileCmdBoss?

Thanks for answers,

Pardál
December 19, 2006
I found that setting it on in a startup service provider wasn't sufficient, since the application turned the setting off after my service provider. I turn it on just before opening the document the image will be placed into, and it seems to be working.
Participant
August 22, 2006
Hi,

I found this thread dealing with the problem that i have but i can't see the final solution to the problem. If anyone could help me i'll appreciate it.

My InDesign CS2 Server pluggin needs to create PDFs and Jpgs from InDesign documents. The PDFs are printed correctly but the Jpegs are exported with gray areas instead of the pictures.

I have tried the IServerSettings and set the SetPreviewImage in many places, at startup, after the doc is open etc. But the gray areas are always there.

If i set the resolution parameter in exportToJpg of snapshotUtils to hiRes the i get th eimage but he jpeg is a bit heavy.

I understand the server set the previews off at start, which makes sense, but then it seems that IServerSettings:SetImagePreview is not able to set it on.

Is this so ? Anyone found the same problem ?

Thanks.
Participating Frequently
March 16, 2006
> After the import.

Try calling it before you process the import command. SetImagePreview is essentially setting a flag (not exactly a preference, as this isn't persistent), which the Place command checks.
Participant
March 16, 2006
>>When did you call this? Before or after the import?
After the import.
I just converted the *.indd file to pdf file manually and saw that the image was retained with its original resolution.
(Later on i will write a script to convert the *.indd to *.pdf file.)

Thanks and Regards,
Yogesh Joshi
Participating Frequently
March 16, 2006
> I tried IServerSettings->SetImagePreview(kTrue)

When did you call this? Before or after the import?

> But when i convert the same *.indd to pdf the image is gettig displayed nicely. (So that was anyhow my final aim.)

Yes, this display performance setting this is only for on-screen viewing. If the datalink to the placed file exists, you'll get the appropriate resolution during output (which of course, you set as image downsampling settings during PDF export)
Participant
March 16, 2006
Thanks both Ken and Marco!!
I tried IServerSettings->SetImagePreview(kTrue)

but its not working for indesignCS2 server.
Still i am not getting rid of the gray box.
But when i convert the same *.indd to pdf the image is gettig displayed nicely.
(So that was anyhow my final aim.)

Thanks again ..You are really a timely help for me.

Thanks and Regards,
Yogesh Joshi
Participating Frequently
March 15, 2006
Thanks Marco for the reminder - that would work too.
IServerSettings is on kSessionBoss - ONLY for InDesign Server. So you try to query it using gSession, and if it is non-nil, you can call its methods.