If WpTools + WpReporter + wPdf FMX can be used on mobile devices, i think it may be an impressive reporting solution for mobile apps who work disconnected.
Posts by enricorav
-
-
Hi Julian,
some news about planning a FireMonkey edition of WpTools/WpReporter? -
Hello,
i need to store a lot of RTF documents on a database.
All this documents are readed from a WPRichText component.
It's better if i use a TMemoField or a TWideMemoField on a database to store this documents?
RTF documents are stored as only ASCII character also if there are chinese or some other unicode languages text in the document? If this is true i can use a TMemoField. This will be true also in the future version of WpTools (i read some topic here about arabic wptools support) ?Best regards,
EnricoWpTools 6.20
RadStudio XE -
Hi Julian
i try to make some improvement to my mail-merge procedure to create a unique RTF document as a result of a sequence of mail-merge using WpReporter.
I have a TWPRichText who is the source for TWPSuperMerge (will call it WPTemplate) another TWPRichText who is the result of the merge (will call it WPMerge) and the last TWPRichText will contain the final document (will call it WPAllMerge).
The mail-merge will process a sequence of "Templates" one-by-one and will create the final document appending any single document as a separate section. I need to preserve header, footer, page settings and page margins of the appended document.
The problem is: for some sections this process seem to work but for some other sections the page margins (left/right) are not the same as the source document.This is who i do
1) clear WPTemplate, WPMerge and WPAllMerge2) load one template into WPTemplate
3) assign header and parStyle from WPTemplate to WPMerge
CodeWPMerge->Clear();WPMerge->Header = WPTemplate->Header; // Assign page propertiesWPMerge->ParStyles()->Assign(WPTemplate->ParStyles());SuperMerge->SetSourceDest(WPTemplate->Memo->RTFData, WPMerge->Memo->RTFData);
3) run SuperMerge->Execute() to create merged document into WPMerge
4) append WPMerge to WPAllMerge as a new section (preserving header and footer, page settings and page margins of WPMerge) using this procedure:
Codevoid __fastcall TMailMergeEngine::AppendAsSection(TWPRichText * WPSource, TWPRichText * WPDest, bool headerAsSource){ TWPRTFSectionProps * sectionprops; TWPRTFDataBlock * textblock ; int i; // Create a new Page if required if (WPDest->IsEmpty()) WPDest->CheckHasBody(); else { WPDest->CPPosition = MaxInt; WPDest->InputString("\f",0); } // Create a new section sectionprops = WPDest->ActiveParagraph->StartNewSection(); // Assign the default page size if (WPSource == WPMerge) sectionprops->Assign(WPSource->Header); //sectionprops->Select = [wpsec_PageSize,wpsec_Margins]; sectionprops->Select << wpsec_PageSize << wpsec_Margins << wpsec_SelectHeaderFooter; // Copy all header + footer into certain section for (i=0; i < WPSource->HeaderFooter->Count; i++ ) { TWPRTFDataBlock * src = WPSource->HeaderFooter->Items[i]; if ( src->Kind == wpHeader || src->Kind == wpFooter ) { textblock = WPDest->HeaderFooter->Append(WPSource->HeaderFooter->Items[i]->Kind, WPSource->HeaderFooter->Items[i]->Range, WPSource->HeaderFooter->Items[i]->Name ); textblock->UsedForSectionID = sectionprops->SectionID; textblock->RtfText->Assign(WPSource->HeaderFooter->Items[i]->RtfText); } } // The current paragraph starts this section WPDest->ActiveParagraph->SectionID = sectionprops->SectionID; // Go to end of file WPDest->CPPosition = MaxInt; //i need to insert a space before coping the text otherwise i cannot see section start simbol on editor WPDest->InputString(' ', 0); // Copy the text as part of a certain section WPDest->SelectionAsString = WPSource->AsANSIString("RTF");}
5) repeat the sequence from step 2 for all documents who i need to process
6) Assign all WPAllMerge contents to WPMerge with this procedure
Codevoid __fastcall TMailMergeEngine::CopyWPText(TWPRichText * WPSource, TWPRichText * WPDest){ WPDest->Clear(); WPDest->AsString = WPSource->AsANSIString("RTF");}
7) save WPMerge on a RTF file
8) open the RTF on a TWPRichText to show or edit it
I tried also to append sections using this code as in your example but the result are worst:
CodeTWPRTFSectionProps * sectionprops = WpEngine->WPAllMerge->HeaderFooter->AppendAsSection(WpEngine->WPMerge->HeaderFooter) sectionprops->Select = sectionprops->Select << wpsec_SelectHeaderFooter
Where is the error?
Best regards,
Enrico Raviglione.RadStudio 2010 C++Builder personality
WpTools v 6.16 -
Hi Julian,
i have modified procedure TDBWPEvalEngine.DoDBCommand to better support empty date/time field and some numeric field type, perhaps you can insert my little changes on standard WpReporter deployment.Code
Display MorewpdField: { Read the contents of the field } begin field := nil; { Concat the strings in the fields. At least one of the fields MUST be found } if aFunction.ParamCount > 1 then begin s := ''; nall := ''; bool := FALSE; for i := 0 to aFunction.ParamCount - 1 do begin n := aFunction.Params[i].StringValue; if nall = '' then nall := n else nall := nall + ',' + n; if data.Active then field := data.FindField(n); if field <> nil then begin bool := TRUE; s := s + field.AsString; end; end; if bool then aFunction.StringValue := s else aFunction.StringValue := Format(FFieldNotFoundText, [nall]); end else { There is only one parameter. Read the correct type for the field } begin try s := aFunction.Params[1].StringValue; if data.Active then field := data.FindField(s) else field := nil; if field = nil then aFunction.StringValue := Format(FFieldNotFoundText, [s]) [start change 1] // 22 Dic 2010 - Enrico - Data and time field changes // else if field is TDateField then // aFunction.DateValue := TDateField(field).AsDateTime else if (field is TDateField) or (field is TDateTimeField) then begin if int(field.AsDateTime) = 0 then aFunction.StringValue := '' else aFunction.StringValue := field.AsString; end // end date and time field changes [end change 1] else if field is TFloatField then aFunction.FloatValue := TFloatField(field).AsFloat else if field is TIntegerField then aFunction.IntValue := TIntegerField(field).AsInteger else if field is TBooleanField then aFunction.BoolValue := TBooleanField(field).AsBoolean [start change 2] // 22 Dic. 2010 - Enrico - New numeric field type else if field is TBCDField then aFunction.FloatValue := TBCDField(field).AsFloat else if field is TCurrencyField then aFunction.FloatValue := TCurrencyField(field).AsFloat else if field is TIntegerField then aFunction.IntValue := TIntegerField(field).AsInteger else if field is TSmallintField then aFunction.IntValue := TSmallintField(field).AsInteger else if field is TLargeintField then aFunction.IntValue := TLargeintField(field).AsInteger // end new numeric field type [end change 2] else aFunction.StringValue := field.AsString; except { Read error Text } on ex: Exception do begin WPEVErrorMessage := ex.Message; aFunction.StringValue := '<ERR: ' + ex.Message + '>'; try aFunction.Error(0, 0); except { we don't want an exceptin here ! } end; end; else raise ; end; end; end; wpdFirst :
Best regards,
Enrico -
Thank you Julian,
exactly what i need!Enrico
-
Well this is the scenario:
- i'm using WpReporter to do mailmerge and this work fine, this aren't the problem.
- i need to modify the rtf document who i use as a source of the mail-merge process before start the mail-merge, will call it rtf1.This its who i need to do:
1) into a TWPRichText i load "rtf1" document from a file on disk;
2) i need to append at the end of "rtf1" body another document: "rtf2"
3) i don't want page break
4) i don't want section break
5) i don't want change the header setting of "rtf1" (page size, margins, etc, etc);
6) rtf2 document it's stored into a DB MemoField.Which are the fast/best method to do this step?
I'm sorry if I was not clear before.
Enrico Raviglione
-
Martens solutions work perfectly but i have discovered who is not who i need because wprtf1 is a mail-merge source so i need to add the text as a "Footer band" at the end of the body and not as a real Footer.
Wich is the fast method to append rtf text at wprtf1 if the text are previously stored into a db memo field by a TDBWPRichText component?Thanks and sorry for my previous question.
Enrico RaviglioneRadStudio 2010 C++Builder personality
WpTools v 6.16 -
Hello Julian,
i need to copy the body of TWPRichText1 as a Footer in a TWPRichText2.
I try this but dont work:Codefor (int i=0; i < WPRtf2->HeaderFooter->Count; i++) { WPRtf1->HeaderFooter->Get(wpIsFooter, wpraOnAllPages, "")->RtfText->AsString = WPRtf2->HeaderFooter->Items[i]->RtfText->AsString; }
How can i do?Best regards,
Enrico.RadStudio 2010 C++Builder personality
WpTools v 6.16 -
I tried to print some chinese report from WpTools 6 to wPdf and i see some strange behaviour, some character and only sometimes seem to be missunderstanded and the PDF don't show exactly the same chinese simbols.
If i print the same report to a printer (alwais from the same wptools object) the text are printed correctly.How i must set wPdf component for support chinese/asian character?
Im using RAD Studio 2010 C++Builder personality, last version of WpTools6 with wpMailMerge and wPdf.
Best regards,
Enrico. -
Hi Julian
i write the code below but nothing appear into the PDF file.
The produced PDF files are alwais (2.244 byte) big, the same size if i don't do the CadPrint ( hDwg, false, DC ); instruction.I attach here my simple code any help would be appreciated.
Best regards,
EnricoQuote
double Resolution = 300; // Dpi
double ResolutionMM = Resolution / 25.4; // Dot per mm
double PaperW = 297; // A4 - Landscape
double PaperH = 210;PDFprn->BeginDoc();
PDFprn->StartPage( (PaperW * ResolutionMM), (PaperH * ResolutionMM), Resolution, Resolution, 0);// This procedure set on CadObject the rectangle of draw to be printed, the page size (A4 Landscape), margins and color/monocrome.
// See below
SetPrintScaleAndOrientation();PDFprn->CanvasReference = wprefPrinter;
HDC DC = PDFprn->Canvas->Handle;CadPrint ( hDwg, false, DC ); // DC will be the handle to printer device context
PDFprn->EndPage();
PDFprn->EndDoc();Quote
void __fastcall SetPrintScaleAndOrientation(void)
{
double x0, y0, x1, y1, xc, yc;CadGetExtentRect ( hDwg, &x0, &y0, &x1, &y1 );
// define a part of drawing to print (coordinates at display projection)
CadPrintPutRect( x0, y0, x1, y1 );// set print parameters so the entire drawing fits to printer paper
int w = x1 - x0;
int h = y1 - y0;// define best orientation
if (w > h)
CadPrintPutOrient( CAD_PAPER_LANDSCAPE );
else
CadPrintPutOrient( CAD_PAPER_PORTRAIT );double PaperW = CadPrintGetPaperW();
double PaperH = CadPrintGetPaperH();double scx = PaperW / w;
double scy = PaperH / h;
double scale = min( scx, scy ) * 0.99;// define an output scale 1:x
CadPrintPutScale( scale );// Centering draw on Paper: set margin left and top of paper
double lMargin = ( PaperW - (scale * w) ) / 2;
double tMargin = ( PaperH - (scale * h) ) / 2;
CadPrintPutOffset( lMargin, tMargin );// Set monochrome or colored
CadPrintPutColor ( false /* monochrome = false */ );
} -
Hi Julian, i use an external DLL to view and print CAD draw.
I need to print the CAD draw into a PDF, the DLL have a function as this:BOOL CadPrint (
VDWG hDwg, // handle to CAD object
BOOL bPrintStamp, // stamp's visibility
HDC hPrinterDC // handle to printer device context
);Can i pass wPDF canvas HDC as hPrinterDC ?
I tryied to do that but i don't see nothing on the PDF, i need to set something else or what i try to do it's simply 'stupid'?Best regards,
Enrico. -
Hi Julian,
can i use wPDF for convert multipage-TIFF to PDF?
I use ImageEN Delphi component for scan, view and print multipage TIFF in my application. Now i need to save TIFF in PDF format for archiving purpose ... can i do this with your wPDF ?
How are the best method for convert and compress the multipage image in PDF? -
Hi Julian,
i need to create a PDF file from a CAD dll. This CAD dll can print it's draw on a default printer or on a specific HDC.
Here my C++Builder function used for print from this CAD dll:Code
Display Morebool __fastcall Tcad::PrintAll(HDC hPrintDC) { bool ok = false; TCursor oldCur = Screen->Cursor; Screen->Cursor = crHourGlass; try { double x0, y0, x1, y1, xc, yc; // get total draw extension CadGetExtentRect ( hDwg, &x0, &y0, &x1, &y1 ); // define a part of drawing to print (coordinates at display projection) CadPrintPutRect( x0, y0, x1, y1 ); // set print parameters so the entire drawing fits to printer paper int w = x1 - x0; int h = y1 - y0; // define best orientation if (w > h) CadPrintPutOrient( CAD_PAPER_LANDSCAPE ); else CadPrintPutOrient( CAD_PAPER_PORTRAIT ); int PaperW = CadPrintGetPaperW(); int PaperH = CadPrintGetPaperH(); double scx = PaperW / w; double scy = PaperH / h; double scale = min( scx, scy ) * 0.99; // define an output scale 1:1 CadPrintPutScale( scale ); if ( hPrintDC ) { // print on a specific printer ok = CadPrint ( hDwg, false, hPrintDC ); } else { // print on default printer ok = CadPrint ( hDwg, false, 0 ); } } __finally { Screen->Cursor = oldCur; return ok; } } //---------------------------------------------------------------------------
Can i use wPDF as a specific printer ?
-
Hi Julian,
how can i change Font and size of the inserted Hyperlink ?
-
Hi Julian,
the bugs who i have reported are not about Tabs. I know who WpTools are not resposible for differences in the display caused by problematic use of tabs.
The bugs who i have reported are:
Quote
1) On First Page: The image are positioned more right comparing them with WpTools4, please verify if this may be a more serious bug in some procedures.2) On Page n. 5: Table are not displayed as in WpTools4 and MsWord.
Into the bitmap attached to my e-mail i have circled in red where are the difference.
-
Hi Julian,
i sended to you an e-mail in date 30.09.2005 :
Quote
i found other 2 problem comparing WpTools5 and WpTools4 as you can see in my attachments.1) The image are positioned more right comparing them with WpTools4, please verify if this may be a more serious bug in some procedures.
2)Table are not displayed as in WpTools4.
Attached to the email you have my examples.
-
Hi Julian,
using the same RTFDataProps for both edits, the template and the destination, WPReporter work fine. Most of the problems disappear.
I sended to you an e-mail with an attachments with descriptions, examples and screenshot of all the remaining little bugs who i found.
Thank you very much.
-
Hi Julian,
i sended to you a detailed e-mail with an attachments with descriptions, examples and screenshot of all the bugs who i found.
Tell me something about that.
-
Hi Julian,
also for me there are some problems with numbers and bullets.
If i open a document with Wpt5, i save it, then i re-open the document the bullets symbols are changed. Before i have a minus symbol '-' after i see a little square.Instead using WpReport (for read a template and generate a report) in my final document i lost some numbers and bullets who are presents into the original template. But attention, not all the paragraphs with numbers and bullets but only some parts of the document are affected by the problems.
I already tried your solution {$IFNDEF SAVE_ALL_NUMSTYLES_WPT} but don't solve the problem.