delphi ole excel container, save file - delphi

what is the syntax for this c++ question in Delphi?
After using an oleContainer, and trying to do SaveDocumentAs which didn't work. I thought this might be a good alternative.
update: thank you for the translation, however the excel file goes curropted after the call
var
ExcelOle: TOleContainer;
begin
ExcelOLE.CreateObjectFromFile(FileName, False);
ExcelOle.OleObject.application.workbooks[1].save;
end;

Simply create an Ole Object:
uses ComObj, Excel;
var Excel: OleVariant;
Excel := CreateOleObject('EXCEL.Application');
Excel.Application.Workbooks.Add;
Excel.Application.Workbooks[1].SaveAs('c:\test.xlsx', xlWorkbookDefault); // or xlOpenXMLWorkbook (51)
Excel.Application.Quit;
Excel.pas
unit Excel;
interface
uses Windows, Activex;
// originally from Excel97.pas
// XlFileFormat constants
type
XlFileFormat = TOleEnum;
const
xlAddIn = $00000012;
xlCSV = $00000006;
xlCSVMac = $00000016;
xlCSVMSDOS = $00000018;
xlCSVWindows = $00000017;
xlDBF2 = $00000007;
xlDBF3 = $00000008;
xlDBF4 = $0000000B;
xlDIF = $00000009;
xlExcel2 = $00000010;
xlExcel2FarEast = $0000001B;
xlExcel3 = $0000001D;
xlExcel4 = $00000021;
xlExcel5 = $00000027;
xlExcel7 = $00000027;
xlExcel9795 = $0000002B;
xlExcel4Workbook = $00000023;
xlIntlAddIn = $0000001A;
xlIntlMacro = $00000019;
xlWorkbookNormal = $FFFFEFD1;
xlSYLK = $00000002;
xlTemplate = $00000011;
xlCurrentPlatformText = $FFFFEFC2;
xlTextMac = $00000013;
xlTextMSDOS = $00000015;
xlTextPrinter = $00000024;
xlTextWindows = $00000014;
xlWJ2WD1 = $0000000E;
xlWK1 = $00000005;
xlWK1ALL = $0000001F;
xlWK1FMT = $0000001E;
xlWK3 = $0000000F;
xlWK4 = $00000026;
xlWK3FM3 = $00000020;
xlWKS = $00000004;
xlWorks2FarEast = $0000001C;
xlWQ1 = $00000022;
xlWJ3 = $00000028;
xlWJ3FJ3 = $00000029;
xlExcel12 =50;
xlExcel8 = 56;
xlHtml = 44;
xlOpenXMLAddIn = 55;
xlOpenXMLTemplate = 54;
xlOpenXMLTemplateMacroEnabled = 53;
xlOpenXMLWorkbook = 51;
xlOpenXMLWorkbookMacroEnabled = 52;
xlTemplate8 = 17;
xlUnicodeText = 42;
xlWebArchive = 45;
xlWorkbookDefault = 51;
xlXMLSpreadsheet = 46;
implementation
end.

Related

How to check if enabling custom invoice numbers results in duplicate invoice Numbers

I am working on integrating quick books with mvc and I have to work on one task which is to check if enabling custom invoice numbers results in duplicate Invoice .
I have tried creating invoice in quick books
public Invoice PostInvoice(InvoiceViewModel model)
{
Intuit.Ipp.Data.Invoice invoice = new Intuit.Ipp.Data.Invoice();
invoice.Deposit = new Decimal(0.00);
invoice.DepositSpecified = true;
invoice.DocNumber = "QBOInvoice" + DateTime.Now.ToString("MMddHHmmss");
invoice.CustomerRef = new ReferenceType { Value = model.qboCustomer.Id };
// invoice.CustomerMemo = new MemoRef { Value = reference };
invoice.DueDate = DateTime.UtcNow.Date;
invoice.DueDateSpecified = true;
invoice.TotalAmtSpecified = true;
invoice.ApplyTaxAfterDiscount = false;
invoice.ApplyTaxAfterDiscountSpecified = true;
invoice.PrintStatus = PrintStatusEnum.NotSet;
invoice.PrintStatusSpecified = true;
invoice.EmailStatus = EmailStatusEnum.NotSet;
invoice.EmailStatusSpecified = true;
invoice.BalanceSpecified = true;
invoice.TxnDate = DateTime.UtcNow.Date;
invoice.TxnDateSpecified = true;
invoice.ShipAddr = model.Address;
invoice.BillAddr = model.Address; //new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
//invoice.ShipAddr = new PhysicalAddress() {Line1="Mohali", Line2="Sector 70 ",City="Mohali",PostalCode="160071" };
//invoice.BillAddr = new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
Intuit.Ipp.Data.Line line = new Intuit.Ipp.Data.Line();
SalesItemLineDetail lineSalesItemLineDetail = new SalesItemLineDetail();
List<Intuit.Ipp.Data.Line> lineList = new List<Intuit.Ipp.Data.Line>();
foreach (var item in model.qbolineitems)
{
lineSalesItemLineDetail = new SalesItemLineDetail();
line = new Intuit.Ipp.Data.Line();
//Line Sales Item Line Detail - ServiceDate
lineSalesItemLineDetail.ServiceDate = DateTime.Now.Date;
lineSalesItemLineDetail.ServiceDateSpecified = true;
lineSalesItemLineDetail.Qty = item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.QtySpecified = true;
lineSalesItemLineDetail.ItemRef = new ReferenceType { Value = item.item.qboItemCode.Value.ToString(), name = item.item.qboItemName };
lineSalesItemLineDetail.AnyIntuitObject = item.invoiceitem.SalePrice.Value / item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
line.AnyIntuitObject = lineSalesItemLineDetail;
line.Description = item.item.qboItemName;
line.Amount = item.invoiceitem.SalePrice.Value;
line.AmountSpecified = true;
// line.Id = item.item.qboItemCode.Value.ToString();
line.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
line.DetailTypeSpecified = true;
//if (_connect.Country == "US")
//{
lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = "TAX" };
//}
//else
//{
//_connect = (Connect)Session["Connect"];
// objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//var taxcode = objQBO.getTaxCodeList().Where(x => x.Active).FirstOrDefault();
//lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = taxcode.Id };
//var dis = item.invoiceitem.SalePrice.Value / (Convert.ToDecimal(taxcode.SalesTaxRateList.TaxRateDetail[0].TaxRateRef.Value) + 1);
//line.Amount = item.invoiceitem.SalePrice.Value - dis;
//lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxInclusiveAmtSpecified = false;
invoice.GlobalTaxCalculationSpecified = false;
invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.NotApplicable;
//SendInsideFunctionEmail("Failed to create surcharge invoice for : " + reference, "Please create a surcharge invoice manually and send a receipt to the customer. Also,please assign the tax code for this account selected in qbo.", _generalSettings.AccountsEmail);
// }
lineList.Add(line);
}
//invoice.TotalAmt = new Decimal(0.90);
//invoice.Balance = new Decimal(0.90);
// xlic.Add(li);
invoice.TotalAmt = model.Total;
invoice.Balance = model.BalanceDue;
invoice.Line = lineList.ToArray();
_connect = (Connect)Session["Connect"];
objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
invoice = objQBO.CreateInvoice(invoice);
return invoice;
}
I expect that generating custom invoice numbers results in duplicate invoice but not finding a way to implement that

Acrobat C Struct to Delphi Record

I'm attempting to utilize Adobe Acrobat OLE to optimize and compress PDFs that we take in through various internal programs. Adobe uses C for all of their documentation, and I'm having trouble converting a structure to a record in Delphi.
Referencing the SDK here:
Adobe struct:
struct _t_PDFOptParams{
ASSize_t size;
ASPathName asPathDest;
ASFileSys fileSys;
ProgressMonitor progMon;
void* progMonClientData;
PDFOptPDFVersion enmAcrobatVersion;
PDFOptImageOptionsRec imageOptionsColor;
PDFOptImageOptionsRec imageOptionsGrayscale;
PDFOptImageOptionsRec imageOptionsMonochrome;
PDFont* arrPDFontsToUnembed;
ASInt32 cPDFontsToUnembed;
PDFOptFlattenTransparencyOptions pdfOptFlattenTransparencyOptions;
ASBool bRemoveFormActions;
ASBool bFlattenFormFields;
ASBool bRemoveJavascriptActions;
ASBool bRemoveAlternateImages;
ASBool bRemoveThumbnails;
ASBool bRemoveDocumentTags;
ASBool bSmoothenLines;
ASBool bMergeImageFragments;
ASBool bRemovePrintSettings;
ASBool bRemoveSrchIndex;
ASBool bRemoveBookmarks;
ASBool bRemoveCommentsAndWidgets;
ASBool bRemoveDocInfoAndMetadata;
ASBool bRemoveObjectData;
ASBool bRemoveFileAttachments;
ASBool bRemoveCrossRefs;
ASBool bRemovePrivateData;
ASBool bFlattenVisibleLayers;
PDFOptObjectCompression enmObjectCompression;
ASBool bUnencodedToFlate;
ASBool bLZWToFlate;
ASBool bRemoveInvalidBookmarks;
ASBool bRemoveInvalidLinks;
ASBool bRemoveUnreferencedNamedDests;
ASBool bLinearize;
}PDFOptParamsRec, *PDFOptParams;
My attempt in Delphi to create a record:
type PDFParams = record
size : byte;
asPathDest : string;
//fileSys : ;
//progMon : null
//progMonClientData : null
//enmAcrobatVersion : PDFOptPDFVersion;
//imageOptionsColor
//imageOptionsGrayscale
//imageOptionsMonochrome
//arrPDFontsToUnembed
cPDFontsToUnembed :Integer;
//pdfOptFlattenTransparencyOptions
bRemoveFormactions : bool;
bFlattenFormFields : bool;
bRemoveJavascriptActions : bool;
bRemoveAlternateImages : bool;
bRemoveThumbnails : bool;
bRemoveDocumentTags : bool;
bSmoothenLines : bool;
bMergeImageFragments : bool;
bRemovePrintSettings : bool;
bRemoveSrchIndex : bool;
bRemoveBookmarks : bool;
bRemoveCommentsAndWidgets: bool;
bRemoveDocInfoAndMetadata: bool;
bRemoveObjectData : bool;
bRemoveFileAttachments : bool;
bRemoveCrossRefs : bool;
bRemovePrivateData : bool;
bFlattenVisibleLayers : bool;
//enmObjectCompression : bool;
bUnencodedToFlate : bool;
bLZWToFlate : bool;
bRemoveInvalidBookmarks : bool;
bRemoveInvalidLinks : bool;
bRemoveUnreferencedNamedDests : bool;
bLinearize : bool;
end;
I'm not sure what I should be setting the commented out fields to?
What you have translated so far is not even close to being accurate. ASSize_t is not a single byte, ASPathName is not a string, ASBool is not a bool, etc.
The PDFOptParams struct has dependencies on a LOT of other types. Based on the PDF, the definitions of those types would look something like this:
type
{ define this manually only if your Delphi version does not already provide it }
size_t = NativeUInt;
ASSize_t = size_t;
ASInt32 = Int32;
ASUns16 = UInt16;
ASBool = ASUns16;
ASDuration = ASInt32;
ASFileMode = ASUns16;
ASMDFile = Pointer;
ASErrorCode = ASInt32;
{ the following types are not documented in the PDF, so you need
to track down what they are actually defined as in the SDK and
translate them as needed... }
_t_ASPathNameRec = record
...
end;
ASPathName = ^_t_ASPathNameRec;
_t_PDFont = record
...
end;
PDFont = ^_t_PDFont;
_t_ASTextRec = record
...
end;
ASText = ^_t_ASTextRec;
{ I'm not going to translate all of the following callback types,
I'll leave that as an exercise for you to do. I've done the 1st
two for you (note: the PDF doesn't describe calling conventions
used, so if 'cdecl' doesn't work, try 'stdcall' instead)... }
ASFileSysOpenProc = function(pathName: ASPathName; mode: ASFileMode; var fP: ASMDFile): ASErrorCode; cdecl;
ASFileSysCloseProc = function(f: ASMDFile): ASErrorCode; cdecl;
ASFileSysFlushProc = ...;
ASFileSysSetPosProc = ...;
ASFileSysGetPosProc = ...;
ASFileSysSetEofProc = ...;
ASFileSysGetEofProc = ...;
ASFileSysReadProc = ...;
ASFileSysWriteProc = ...;
ASFileSysRemoveProc = ...;
ASFileSysRenameProc = ...;
ASFileSysIsSameFileProc = ...;
ASFileSysGetNameProc = ...;
ASFileSysGetTempPathNameProc = ...;
ASFileSysCopyPathNameProc = ...;
ASFileSysDiPathFromPathProc = ...;
ASFileSysPathFromDIPathProc = ...;
ASFileSysDisposePathNameProc = ...;
ASFileSysGetFileSysNameProc = ...;
ASFileSysGetStorageFreeSpaceProc = ...;
ASFileSysFlushVolumeProc = ...;
ASFileSysGetFileFlags = ...;
ASFileSysAsyncReadProc = ...;
ASFileSysAsyncWriteProc = ...;
ASFileSysAsyncAbortProc = ...;
ASFileSysYieldProc = ...;
ASFileSysMReadRequestProc = ...;
ASFileSysGetStatusProc = ...;
ASFileSysCreatePathNameProc = ...;
ASFileSysAcquireFileSysPathProc = ...;
ASFileSysClearOutstandingMReadsProc = ...;
ASFileSysGetItemPropsProc = ...;
ASFileSysFirstFolderItemProc = ...;
ASFileSysNextFolderItemProc = ...;
ASFileSysDestroyFolderIteratorProc = ...;
ASFileSysSetModeProc = ...;
ASFileSysURLFromPathProc = ...;
ASFileSysGetParentProc = ...;
ASFileSysCreateFolderProc = ...;
ASFileSysRemoveFolderProc = ...;
ASFileSysDisplayStringFromPathProc = ...;
ASFileSysSetTypeAndCreatorProc = ...;
ASFileSysGetTypeAndCreatorProc = ...;
ASFileSysReopenProc = ...;
ASFileSysHardFlushProc = ...;
ASFileSysGetPlatformThingProc = ...;
ASFileSysGetItemPropsAsCabProc = ...;
ASFileSysCanPerformOpOnItemProc = ...;
ASFileSysPerformOpOnItemProc = ...;
ASFileSysAcquirePlatformPathProc = ...;
ASFileSysReleasePlatformPathProc = ...;
ASFileSysGetNameAsASTextProc = ...;
ASFileSysDisplayASTextFromPathProc = ...;
ASFileSysRangeArrivedProc = ...;
ASFileSysCanSetEofProc = ...;
ASFileSysDIPathFromPathExProc = ...;
ASFileSysPathFromDIPathExProc = ...;
ASFileSysGetFilePositionLimitProc = ...;
ASFileSysOpen64Proc = ...;
ASFileSysSetPos64Proc = ...;
ASFileSysGetPos64Proc = ...;
ASFileSysSetEof64Proc = ...;
ASFileSysGetEof64Proc = ...;
ASFileSysGetNameForDisplayProc = ...;
ASFileSysGetStorageFreeSpace64Proc = ...;
_t_ASFileSysRec = record
size: ASSize_t;
open: ASFileSysOpenProc;
close: ASFileSysCloseProc;
flush: ASFileSysFlushProc;
setpos: ASFileSysSetPosProc;
getpos: ASFileSysGetPosProc;
seteof: ASFileSysSetEofProc;
geteof: ASFileSysGetEofProc;
read: ASFileSysReadProc;
write: ASFileSysWriteProc;
remove: ASFileSysRemoveProc;
rename: ASFileSysRenameProc;
isSameFile: ASFileSysIsSameFileProc;
getName: ASFileSysGetNameProc;
getTempPathName: ASFileSysGetTempPathNameProc;
copyPathName: ASFileSysCopyPathNameProc;
diPathFromPath: ASFileSysDiPathFromPathProc;
pathFromDIPath: ASFileSysPathFromDIPathProc;
disposePathName: ASFileSysDisposePathNameProc;
getFileSysName: ASFileSysGetFileSysNameProc;
getStorageFreeSpace: ASFileSysGetStorageFreeSpaceProc;
flushVolume: ASFileSysFlushVolumeProc;
getFileFlags: ASFileSysGetFileFlags;
readAsync: ASFileSysAsyncReadProc;
writeAsync: ASFileSysAsyncWriteProc;
abortAsync: ASFileSysAsyncAbortProc;
yield: ASFileSysYieldProc;
mreadRequest: ASFileSysMReadRequestProc ;
getStatus: ASFileSysGetStatusProc;
createPathName: ASFileSysCreatePathNameProc;
acquireFileSysPath: ASFileSysAcquireFileSysPathProc;
clearOutstandingMReads: ASFileSysClearOutstandingMReadsProc;
getItemProps: ASFileSysGetItemPropsProc;
firstFolderItem: ASFileSysFirstFolderItemProc;
nextFolderItem: ASFileSysNextFolderItemProc;
destroyFolderIterator: ASFileSysDestroyFolderIteratorProc;
setFileMode: ASFileSysSetModeProc;
urlFromPath: ASFileSysURLFromPathProc;
getParent: ASFileSysGetParentProc;
createFolder: ASFileSysCreateFolderProc;
removeFolder: ASFileSysRemoveFolderProc;
displayStringFromPath: ASFileSysDisplayStringFromPathProc;
setTypeAndCreator: ASFileSysSetTypeAndCreatorProc;
getTypeAndCreator: ASFileSysGetTypeAndCreatorProc;
reopen: ASFileSysReopenProc;
hardFlush: ASFileSysHardFlushProc;
getPlatformThing: ASFileSysGetPlatformThingProc;
getItemPropsAsCab: ASFileSysGetItemPropsAsCabProc;
canPerformOpOnItem: ASFileSysCanPerformOpOnItemProc;
performOpOnItem: ASFileSysPerformOpOnItemProc;
acquirePlatformPath: ASFileSysAcquirePlatformPathProc;
releasePlatformPath: ASFileSysReleasePlatformPathProc;
getNameAsASText: ASFileSysGetNameAsASTextProc;
displayASTextFromPath: ASFileSysDisplayASTextFromPathProc;
rangeArrived: ASFileSysRangeArrivedProc;
canSetEof: ASFileSysCanSetEofProc;
diPathFromPathEx: ASFileSysDIPathFromPathExProc;
pathFromDIPathEx: ASFileSysPathFromDIPathExProc;
getfileposlimit: ASFileSysGetFilePositionLimitProc;
open64: ASFileSysOpen64Proc;
setpos64: ASFileSysSetPos64Proc;
getpos64: ASFileSysGetPos64Proc;
seteof64: ASFileSysSetEof64Proc;
geteof64: ASFileSysGetEof64Proc;
getNameForDisplay: ASFileSysGetNameForDisplayProc;
getStorageFreeSpace64: ASFileSysGetStorageFreeSpace64Proc;
end;
ASFileSysRec = _t_ASFileSysRec;
ASFileSys = ^_t_ASFileSysRec;
PMBeginOperationProc = procedure(clientData: Pointer); cdecl;
PMEndOperationProc = procedure(clientData: Pointer); cdecl;
PMSetDurationProc = procedure(duration: ASDuration; clientData: Pointer); cdecl;
PMSetCurrValueProc = procedure(currValue: ASDuration; clientData: Pointer); cdecl;
PMGetDurationProc = function(clientData: Pointer): ASDuration; cdecl;
PMGetCurrValueProc = function(clientData: Pointer): ASDuration;
PMSetTextProc = procedure(text: ASText; clientData: Pointer); cdecl;
_t_ProgressMonitor = record
size: ASSize_t;
beginOperation: PMBeginOperationProc;
endOperation: PMEndOperationProc;
setDuration: PMSetDurationProc;
setCurrValue: PMSetCurrValueProc;
getDuration: PMGetDurationProc;
getCurrValue: PMGetCurrValueProc;
setText: PMSetTextProc;
end;
ASProgressMonitorRec = _t_ProgressMonitor;
ASProgressMonitor = ^_t_ProgressMonitor;
ProgressMonitor = ASProgressMonitor;
PDFOptPDFVersion = (kPDFOptRetainVersion = 0, kPDFOptAcrobat4, kPDFOptAcrobat5, kPDFOptAcrobat6, kPDFOptAcrobat7, kPDFOptAcrobat8);
PDFOptDownsamplingAlgo = (kPDFOptNoDownsampling = 0, kPDFOptAverage, kPDFOptSubsampling, kPDFOptBicubic);
PDFOptCompressionAlgo = (kPDFOptNoRecompression = 0, kPDFOptJpeg2000, kPDFOptJpeg, kPDFOptFlate, kPDFOptJBIG2, kPDFOptCCITT3, kPDFOptCCITT4, kPDFOptRunLengh);
PDFOptCompressionQlty = (kPDFOptMinimumQlty = 0, kPDFOptLowQlty, kPDFOptMediumQlty, kPDFOptHighQlty, kPDFOptMaximumQlty, kPDFOptLossless);
_t_PDFOptImageOptions = record
size: ASSize_t;
enmDownsamplingAlgo: PDFOptDownsamplingAlgo;
ppiDownsampleTo: ASInt32;
ppiDownsampleAbove: ASInt32;
enmCompressionAlgo: PDFOptCompressionAlgo;
enmCompressionQlty: PDFOptCompressionQlty;
nTileSize: ASInt32;
end;
PDFOptImageOptionsRec = _t_PDFOptImageOptions;
PDFOptImageOptions = ^_t_PDFOptImageOptions;
_t_PDFOptFlattenTransparencyOptions = record
size: ASSize_t;
pctRasterVectorBalance,
ppiLineArtAndText,
ppiGradientAndMesh: ASInt32;
bConvertText,
bConvertStrokes,
bClipComplexRegions,
bPreserveOverprint: ASBool;
end;
PDFOptFlattenTransparencyOptionsRec = _t_PDFOptFlattenTransparencyOptions;
PDFOptFlattenTransparencyOptions = ^_t_PDFOptFlattenTransparencyOptions;
PDFOptObjectCompression = (kPDFOptUntouchedCompression = 0, kPDFOptFullCompression, kPDFOptPartialCompression, kPDFOptRemoveCompression);
_t_PDFOptParams = record
size: ASSize_t;
asPathDest: ASPathName;
fileSys: ASFileSys;
progMon: ProgressMonitor;
progMonClientData: Pointer;
enmAcrobatVersion: PDFOptPDFVersion;
imageOptionsColor,
imageOptionsGrayscale,
imageOptionsMonochrome: PDFOptImageOptionsRec;
arrPDFontsToUnembed: ^PDFont;
cPDFontsToUnembed: ASInt32;
pdfOptFlattenTransparencyOptions: PDFOptFlattenTransparencyOptions;
bRemoveFormActions,
bFlattenFormFields,
bRemoveJavascriptActions,
bRemoveAlternateImages,
bRemoveThumbnails,
bRemoveDocumentTags,
bSmoothenLines,
bMergeImageFragments,
bRemovePrintSettings,
bRemoveSrchIndex,
bRemoveBookmarks,
bRemoveCommentsAndWidgets,
bRemoveDocInfoAndMetadata,
bRemoveObjectData,
bRemoveFileAttachments,
bRemoveCrossRefs,
bRemovePrivateData,
bFlattenVisibleLayers: ASBool;
enmObjectCompression: PDFOptObjectCompression;
bUnencodedToFlate,
bLZWToFlate,
bRemoveInvalidBookmarks,
bRemoveInvalidLinks,
bRemoveUnreferencedNamedDests,
bLinearize: ASBool;
end;
PDFOptParamsRec = _t_PDFOptParams;
PDFOptParams = ^_t_PDFOptParams;

Automatically Slicing Large TIFF File with Photoshop and Save Slices into TIFF Files?

I have a TIFF file. I want to slice it automatically (specifying the number of slices in horizontal and vertical) and save them into TIFF files (I don't want to change the format to png or ...)
I know that in photoshop you can choose the slice tool>>right click>>Divide Slice>>Save for web
However, the "Save for web" doesn't offer saving in TIFF Format and also I don't think it can work for large file (which is the case here).
Anything that can help (script, plugin) is welcome
With the help of some online codes, I created the script below which is capable of automatically slicing a big TIFF into smaller Tiff files:
#target photoshop
function main(){
if(!documents.length) return;
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,380,290],"+
"panel0:Panel{bounds:[10,10,270,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"title:StaticText{bounds:[60,10,220,40] , text:'File Chop' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,40,250,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,111,30] , text:'Accross' ,properties:{scrolling:undefined,multiline:undefined}},"+
"statictext2:StaticText{bounds:[140,10,230,27] , text:'Down' ,properties:{scrolling:undefined,multiline:undefined}},"+
"across:DropDownList{bounds:[10,30,100,50]},"+
"down:DropDownList{bounds:[140,30,230,50]},"+
"saveFiles:Checkbox{bounds:[10,60,230,80] , text:'Save and Close new files?'}},"+
"button0:Button{bounds:[10,140,110,160] , text:'Ok' },"+
"button1:Button{bounds:[150,140,250,160] , text:'Cancel' }}};"
var win = new Window(dlg,'File Chop');
if(version.substr(0,version.indexOf('.'))>9){
win.panel0.title.graphics.font = ScriptUI.newFont("Georgia","BOLD",20);
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [1.00, 1.00, 1.00, 1]);
g.backgroundColor = myBrush;
var myPen =g.newPen (g.PenType.SOLID_COLOR, [1.00, 0.00, 0.00, 1],lineWidth=1);
}
win.center();
for(var i=1;i<31;i++){
win.panel0.panel1.across.add ('item', i);
win.panel0.panel1.down.add ('item', i);
}
win.panel0.panel1.across.selection=0;
win.panel0.panel1.down.selection=0;
var done = false;
while (!done) {
var x = win.show();
if (x == 0 || x == 2) {
win.canceled = true;
done = true;
} else if (x == 1) {
done = true;
{
if(!documents.length)return;
var startRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
doc = app.activeDocument;
app.displayDialogs = DialogModes.NO;
doc.flatten();
var tilesAcross = parseInt(win.panel0.panel1.across.selection.index)+1;
var tilesDown =parseInt(win.panel0.panel1.down.selection.index)+1;
var tileWidth = parseInt(doc.width/tilesAcross);
var tileHeight = parseInt(doc.height/tilesDown);
var SaveFiles = win.panel0.panel1.saveFiles.value;
ProcessFiles(tilesDown,tilesAcross,tileWidth,tileHeight,SaveFiles);
app.preferences.rulerUnits = startRulerUnits;
}
}
}
}
main();
function ProcessFiles(Down,Across,offsetX,offsetY,SaveFiles){
try{
var newName = activeDocument.name.match(/(.*)\.[^\.]+$/)[1];
}catch(e){var newName="UntitledChop"}
var Path='';
try{
Path = activeDocument.path;
}catch(e){Path = "~/Desktop";}
if(SaveFiles){
Path = Folder(decodeURI(Path) +"/FileChop");
if(!Path.exists) Path.create();
}
TLX = 0; TLY = 0; TRX = offsetX; TRY = 0;
BRX = offsetX; BRY = offsetY; BLX = 0; BLY = offsetY;
for(var a = 0; a < Down; a++){
for(var i = 0;i <Across; i++){
var NewFileName = newName +"#"+a+"-"+i;
app.activeDocument.duplicate (NewFileName, true);
activeDocument.selection.select([[TLX,TLY],[TRX,TRY],[BRX,BRY],[BLX,BLY]], SelectionType.REPLACE, 0, false);
executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
app.activeDocument.selection.deselect();
if(SaveFiles){
var saveFile = File(decodeURI(Path+"/"+NewFileName+".tiff"));
SaveTIFF(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
activeDocument = documents[0];
TLX = offsetX * (i+1) ; TRX = TLX + offsetX; BRX = TRX; BLX = TLX;
}
TLX = 0; TLY = offsetY * (a +1); TRX = offsetX; TRY = offsetY * (a +1);
BRX = offsetX; BRY = TRY + offsetY; BLX = 0; BLY = (offsetY * (a +1)+offsetY);
}
if(SaveFiles){
Path.execute()
}
}
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.NONE;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}

Join a Line and Ellipse

I did find how to bind a line to an ellipse through XAML, but I'm not very familiar with binding, and though I've researched it, I still don't understand how to get binding to work with user input.
Is there a way, programmatically to have an ellipse joined to the end of a line so when the line rotates on a diameter, the ellipse rotates with it? Everything I wrote for this is done in the code, not XAML.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void geo()
{
freeCanvas.Children.Clear();
double one, two, three, four, ang;
if(double.TryParse(txtOne.Text, out one))
if(double.TryParse(txtTwo.Text, out two))
if(double.TryParse(txtThree.Text, out three))
if (double.TryParse(txtFour.Text, out four))
if(double.TryParse(txtAngle.Text, out ang))
{
RotateTransform ans = new RotateTransform();
ans.Angle = ang;
ans.CenterX = 75;
ans.CenterY = 150;
Line lineA = new Line();
lineA.Stroke = Brushes.Black;
lineA.StrokeThickness = 2;
lineA.X1 = 75;
lineA.Y1 = 150;
lineA.X2 = 75;
lineA.Y2 = 250;
lineA.HorizontalAlignment = HorizontalAlignment.Center;
lineA.VerticalAlignment = VerticalAlignment.Top;
freeCanvas.Children.Add(lineA);
Line lineB = new Line();
lineB.Stroke = Brushes.Black;
lineB.StrokeThickness = 2;
lineB.X1 = 75;
lineB.Y1 = 50;
lineB.X2 = 75;
lineB.Y2 = 150;
//lineB.HorizontalAlignment = HorizontalAlignment.Center;
//lineB.VerticalAlignment = VerticalAlignment.Top;
lineB.RenderTransform = ans;
freeCanvas.Children.Add(lineB);
Line lineC = new Line();
lineC.Stroke = Brushes.Black;
lineC.StrokeThickness = 2;
lineC.X1 = -25;
lineC.Y1 = 150;
lineC.X2 = 175;
lineC.Y2 = 150;
lineC.HorizontalAlignment = HorizontalAlignment.Center;
lineC.VerticalAlignment = VerticalAlignment.Top;
freeCanvas.Children.Add(lineC);
PathFigure pthFigure = new PathFigure();
pthFigure.StartPoint = new Point(-25, 150);
ArcSegment arcSeg = new ArcSegment();
arcSeg.Point = new Point(175, 150);
arcSeg.Size = new Size(100, 100);
arcSeg.IsLargeArc = true;
arcSeg.SweepDirection = SweepDirection.Clockwise;
arcSeg.RotationAngle = 90;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(arcSeg);
pthFigure.Segments = myPathSegmentCollection;
PathFigureCollection pthFigureCollection = new PathFigureCollection();
pthFigureCollection.Add(pthFigure);
PathGeometry pthGeometry = new PathGeometry();
pthGeometry.Figures = pthFigureCollection;
Path arcPath = new Path();
arcPath.Stroke = new SolidColorBrush(Colors.Black);
arcPath.StrokeThickness = 1.5;
arcPath.Data = pthGeometry;
//arcPath.Fill = new SolidColorBrush(Colors.Yellow);
freeCanvas.Children.Add(arcPath);
Ellipse ellA = new Ellipse();
ellA.Width = 10;
ellA.Height = 10;
ellA.Stroke = Brushes.Black;
ellA.Fill = Brushes.Lime;
TranslateTransform ella1 = new TranslateTransform(70, 145);
ellA.RenderTransform = ella1;
freeCanvas.Children.Add(ellA);
Ellipse ellB = new Ellipse();
ellB.Width = 10;
ellB.Height = 10;
ellB.Stroke = Brushes.Black;
ellB.Fill = Brushes.Yellow;
TranslateTransform ellb1 = new TranslateTransform(70, 45);
ellB.RenderTransform = ellb1;
freeCanvas.Children.Add(ellB);
}
}
private void btnTest_Click(object sender, RoutedEventArgs e)
{
geo();
}
}
}
Never mind, I figured it out. I posted the segment of code that provided the answer.
Rads = Math.PI * ang / 180;
x1 = Math.Sin(Rads) * 80;
y1 = Math.Cos(Rads) * 80;
x2 = Math.Sin(Rads) * 30;
y2 = Math.Cos(Rads) * 30;
Ellipse ellA = new Ellipse();
ellA.Width = 10;
ellA.Height = 10;
ellA.Stroke = Brushes.Black;
ellA.Fill = Brushes.Lime;
TranslateTransform ella1 = new TranslateTransform(70 + x1, 145 - y1);
ellA.RenderTransform = ella1;
freeCanvas.Children.Add(ellA);
Ellipse ellB = new Ellipse();
ellB.Width = 10;
ellB.Height = 10;
ellB.Stroke = Brushes.Black;
ellB.Fill = Brushes.Yellow;
TranslateTransform ellb1 = new TranslateTransform(70 + x2, 145 - y2);
ellB.RenderTransform = ellb1;
freeCanvas.Children.Add(ellB);

Getting Error In Journal Entry Quickbooks

I am trying to add a journal entry. But it returns like an error
Uncaught IdsException: [0]: 2014-01-29 08:13:07 - D:\DummyApps\v3-php-sdk-2.0.1\v3-php-sdk-2.0.1\DataService\DataService.php - 341 - CheckNullResponseAndThrowException -
Response Null or Empty thrown in D:\DummyApps\v3-php-sdk-2.0.1\v3-php-sdk-2.0.1\Core\CoreHelper.php on line 95'
I am using QuickBooks PHP SDK. My code is below:
// Prep Data Services
$dataService = new DataService($serviceContext);
if (!$dataService)
exit("Problem while initializing DataService.\n");
$linedet = new IPPJournalEntryLineDetail();
$linedet->PostingType = 'Credit';
$linedet->AccountRef = 9;
$line = new IPPLine();
$line->Id = 0;
$line->Description = 'test journal';
$line->Amount = 2.00;
$line->DetailType= 'test ';
$line->JournalEntryLineDetail = $linedet;
$linedet2 = new IPPJournalEntryLineDetail();
$linedet2->PostingType = 'Debit';
$linedet2->AccountRef = 9;
$line2 = new IPPLine();
$line2->Id = 1;
$line2->Description = 'test journal';
$line2->Amount = 2.00;
$line2->DetailType= 'test ';
$line2->JournalEntryLineDetail = $linedet2;
// Add a journal
$journalObj = new IPPJournalEntry();
$journalObj->SyncToken = '1';
$journalObj->DocNumber = '1';
$journalObj->TxnDate = '2014-12-30';
$journalObj->RefNumber = 't123';
$journalObj->PrivateNote = 'Just testing';
$journalObj->Line = array($line, $line2);
$journalObj->Adjustment = TRUE;
$journalObj->IsAdjustment = TRUE;
$resultingObj = $dataService->Add($journalObj );
Please help me....I am stuck here.
Thanks in Advance
I found the error here.
The 'DetailType' in the line object must have 'JournalEntryLineDetail'

Resources