Beiträge von gsaunders

    Zitat von wpsupport

    First,

    please note: DrawTGraphic does NOT draw on the "Canvas" of wPDF. Instead it exports an image directly to PDF. If it is a metafdile the vectors will be translated to PDF code, if it is an image, the image will be embedded and used. (It can be used later again with UseBitmap and the ID)

    Sorry for my incorrect terminology... I have studied through it and more and more it is clearing up.

    Zitat von wpsupport

    When printing a wptools watermark You should use Canvas.StretchDraw, not DrawTGraphic.

    Yes... I have only used the StretchDraw (played with Draw) for the OnWatermark event. I used the DrawTGraphic only for wPDF.

    I have been working with the different reports individually for testing so I don't have any issues do to mixing reports... I think for me the biggest problem is just understanding the whole graphic system and what to do to calculate the left, rigth, top, bottom, width, height values needed for various methods. Like when am I looking at twips versus some other unit. Or what units am I looking at in the first place. Or what resolution do I deal with... screen or printer. I think it is mostly just understanding these new things as I have mostly done database work and not anything related to drawing on a canvas or anything dealing in the graphic world.

    And in the other post you will see the the issue with the OnWatermark and going to wPDF and how it also caused issues with the DrawTGraphic. But that's another post.

    Thanks

    Zitat von gsaunders

    Well... I say I was able to get it to work with DrawTGraphic, but at the moment I can't for the life of me get the DrawTGraphic to put it on there and be visible. I get an image_id back so wPDF thinks it put it on the PDF, but when you view it you never see it.

    I know it put it in there as I see the file size increases.

    I tried to view it with PDFView Plus and when it opens the file up I get the following error: "Can't allocate the DIB handle". I used the PDFView demo code.

    But after continuing to run the program the PDF finally comes up and I do see the graphic, but obviously something is wrong as PDFView will eventually show it, but NOT Adobe.

    Ok... the reason for the strange problems with the DrawTGraphic is because the OnWatermark for the WPRichText was still active for the wppInPaintForwPDF. Once I told it to not include for wppInPaintForwPDF then the DrawTGraphic started working and I also figured out the right math to get my bmp centered.

    I still don't know why it can't pick up from the OnWaterMark event of the wprichtext. Certainly would save a step.

    For those interested I used this to get the BMP centered:

    Code
    image_id := DrawTGraphic((MulDiv(w, xres, WPScreenPixelsPerInch) - MulDiv(aGraphic.Width, xres, WPScreenPixelsPerInch)) div 2,
    (MulDiv(h, yres, WPScreenPixelsPerInch) - MulDiv(aGraphic.Height, yres, WPScreenPixelsPerInch)) div 2,
    MulDiv(aGraphic.Width, xres, WPScreenPixelsPerInch),
    MulDiv(aGraphic.Height, yres, WPScreenPixelsPerInch),
    aGraphic);

    I was also able to use a RLE compressed BMP which saved in file size as well.

    Again... I think the OnWaterMark issue should be addressed as it should work.

    Zitat von gsaunders

    Julian,

    Yes I tried this and it didn't make a difference when printing to wPDF. The only way I could get what would look like a watermark on the wPDF was to do it directly in the MakePDF call of mine and doing a DrawTGraphic. Although I am having some alignment issues it is showing up that way.

    But why will it not use what wpTools properly shows when printing to printer???

    Well... I say I was able to get it to work with DrawTGraphic, but at the moment I can't for the life of me get the DrawTGraphic to put it on there and be visible. I get an image_id back so wPDF thinks it put it on the PDF, but when you view it you never see it.

    I know it put it in there as I see the file size increases.

    I tried to view it with PDFView Plus and when it opens the file up I get the following error: "Can't allocate the DIB handle". I used the PDFView demo code.

    But after continuing to run the program the PDF finally comes up and I do see the graphic, but obviously something is wrong as PDFView will eventually show it, but NOT Adobe.

    We are using the OnPaintWatermark in wptools to create a watermark on the screen and printer. This watermark is a BMP image loaded like this:

    Code
    toCanvas.StretchDraw(PageRect, imgWatermarkPortrait1.Picture.Bitmap);

    Now this BMP is close to 856K and is nothing more than large font text centered and saying "This is NOT a Legal Document. Internal Use Only"

    Now... shouldn't I be able to do the same thing, but instead of drawing a graphic, I draw the actual text in large font centered on the screen or is that not possible? Would that simply shift the existing text around?

    And the same question for wPDF... right now I am having to use a DrawTGraphic which leads to a much larger PDF files size. Couldn't I just draw the same image, but as text?

    I know with PDF you can have text objects that overlap so there may be a way to do this so I don't have such a large file size. Not so sure about the wpTools part.

    Zitat von wpsupport

    Hi,

    I would first simplyfy the printing rectnagle. Did You use StretchDraw(PageRect, image) ?

    Julian

    Julian,

    Yes I tried this and it didn't make a difference when printing to wPDF. The only way I could get what would look like a watermark on the wPDF was to do it directly in the MakePDF call of mine and doing a DrawTGraphic. Although I am having some alignment issues it is showing up that way.

    But why will it not use what wpTools properly shows when printing to printer???

    1) So use one of the modes settings (CIdFonts / ExactTextPlacement) AND the CanvasReference to printer at the same time?

    2) If I use the CanvasReference as printer will I have to change calculations because of resolution changes? (This part gets a little confusing at times).

    3) As you know I have a class inherited from TWPPDFPrinter that allows me to call multiple MakePDF for various report types like FastReports, Ace and WPTools. So if I do a begindoc and the canvasreference for the first report is set to screen for wptools, but then I go and print this ace report and have to switch canvasreference to printer will it cause problems doing this between one begindoc / enddoc? Meaning can I switch the canvasreference from one page to the next depending on the report source?

    Ok... I don't know about you, but when I look at drawing a graphic for a watermark or drawing whatever to the canvas (both wPDF and wpTools) I sometimes just glaze over. Mainly because I have only done it a few times and haven't done an in depth study of the different calculations and all the different units that might be used and what coordinate system and so forth.

    So what I thought would be useful would be someone giving a good fundamentals of drawing to the canvas and the mathmatical background behind it and the units being used... especially pertaining to wptools and wpdf.

    For instance when you look at some of the source code or examples you see things that might reference CM (Centimeters) or pixels or twips or x per inch, or MulDiv this or round that. And what happens if you switch from dealing with the screen and now deal with the printer. In some areas I see it changes things all over again.

    My point is it can be a little confusing when you first start looking at this and it would be great if we had a good tutorial along with clear examples of things like:

    wPDF Canvas and WPTools Canvas and when printing...
    - Drawing a graphic to fill the entire page
    - Drawing a graphic to be positioned in the center of the page and stay the original dimensions (no streching)
    - Drawing a graphic and rotating it x degrees on the center of the page
    - Positioning text
    - Drawing graphics to be in the various corners of the canvas.
    - What to do when printing versus to the screen if anything.

    On reason I bring this up is because I am simply trying to use the DrawTGraphic to place a graphic (like a watermark) on the cavas of the wpdf and I am having a heck of a time just centering the stink'n thing. In other areas I see the MulDiv(w, xres, WPScreenPixelsPerInch) and xres and yres get their falues from the FFont?PixeslPerInch so then I start wondering what the heck do I use for x, y, w, h of the DrawTGraphic to get this thing in the center of the page, but no matter what I just miss the mark.

    Like when do I need to use the MulDiv and when not?

    Anyway... I think you get the picture and any feedback or helpful things you do to help you follow the Delphi coordinate, graphic, unit system would be helpful.

    What I had to do was disconnect the WPToolBar from the WPRichText and then change WPToolBar.Enabled to false. Then when needed I reconnect and re-enable.

    It just seems to me like simply setting WPToolBar.Enabled to false should be all that is needed. Just my thought.

    Using D6, WPTools5.x.

    I have a WPRichText which is connected to a WPToolBar.

    In design time I can mark the WPToolBar.Enabled as false and I see that the tool bar is disabled. However when I run the program it is not disabled, but instead enabled.

    What gives?

    It looks like the fact it is connected to a WPRichText that you can't disable it.

    Thanks,

    Greg

    Currently using WPTools 5.x and wPDF 2.x.

    I have the following code to generate watermark when printing to printer from wptools 5.x:

    Code
    if (wppOutputToPrinter in PaintMode) OR (wppInPaintForwPDF in PaintMode) then  begin    if (NOT dmContract.DoPrintAsExecuted) then    begin      imgWidth := imgNotLegal.Picture.Bitmap.Width;      imgHeight := imgNotLegal.Picture.Bitmap.Height;      toCanvas.StretchDraw(Rect((PageRect.Left + Round(PageRect.Right * 0.20)), (PageRect.Top + Round(PageRect.Bottom * 0.35)), (PageRect.Right - Round(PageRect.Right * 0.20)), (PageRect.Bottom - Round(PageRect.Bottom * 0.35))), imgNOTLegal.Picture.Bitmap);    end;  end;

    And here is the code for the printing to pdf:

    Not sure what is wrong here.

    Thanks,

    Greg

    I thought I had tried and it didn't work, but at this point I couldn't swear by it. I have it working with WPDFPrinter for WPRichText so I am good for now. (Still an issue with ace report in another post though).

    Greg

    Zitat von wpsupport

    Hi,

    If it works, don't change it. It is a solution which is not required for all database servers. WPTools is quite independent to it, it just needs its RTF or WPT code in single byte buffers, not unicode strings. The formats WPT and RTF are in fact ASCI formats, only RTF also allows binary but never more than 1 byte per character.

    So I do not have a universal answer for YOu - it really depends.

    Julian

    I did find that I had to change to RTFnoBinary for the images to stay and not truncate text after it when using WPRichText. We had not really used images before until now.

    According to the following http://wpcubed.com/forum/viewtopic.php?t=4920 we should be using varbinary as the field type for wptools data.

    From the early days our fields were set as MS SQL Text data type. To date it has worked as we have only been saving text and not including images.

    1) What are the downsides of leaving this as Text and not changing over to varbinary?

    2) If we really need to switch from Text to VarBinary what will happen to the data if we simply change the data type. Will MS SQL have any issues with this? Or do you have a recommended way of switching existing data from Text data type to the varbinary data type... if we need to.

    Thanks,

    Greg

    I have done further testing and still cannot get this weird spacing to stop. When I print this ace report to PrimoPDF or BlueBeamPDF (PDF Printer drivers) they come out perfect.

    I realized WPCubed is shutdown for the week, but hopefully someone will see this and give some feedback.

    I tried the wPDF v3 demo and it didn't make a difference.

    Thanks in advance.

    I found the wpDontAdjustTextSpacing mode and turned that on.

    That made the resulting PDF very, very close to what the original report looks like. Unfortunately there were a couple of spots where text overwrote each other. But other than that it looked great... but of course I can't use it like that.

    This is a show stopper if we can't get it to generate a report looking like the original.

    We have upgraded from wPDF 2.x to 3.x this Friday, but looks like WPCubed is closed for the week so we may not get the license key to install it for another week and we need this working asap.

    So any help would be appreciated.

    Greg

    Delphi 6, WPTools 5.x, WPDF 2.x

    I didn't notice it originally, but the PDF file we are generating from our ACE Reports using WPDF has some strange looking spacing. Like some things look too close together and the spacing is very tight.

    Heck... it even has a slightly misaligned look... meaning some letters look higher or lower than the letter next to it... ever so slightly.

    Here is the code for this generation:

    Perhaps using the printer as the canvas reference instead of the default display... if this is even part of the issue.

    Thanks in advance.

    Zitat von wpsupport

    Hi,

    There is the event
    OnBeforePrintPage: TWPPDFPrintPageEvent

    That could be used to print anything before any other wptools output. Unfortunately this event is yet not been called for tghe other output. That would be possible to do though. I think about that.

    T print righjt alignt I usually measure the width of the string and subtract that value from the desired end position for text out.

    Julian

    I guess I don't fully understand the WPDF product, but it appears I can do the Canvas.TextOut(?,?,?) and I see it show up on the PDF. My only issue is determining what calculations to use to make sure I have it in the same spot every time.

    It seems that I should be able to use the width and height of the page and then subtract the proper numbers to position it at the same spot every time. But what I don't know is what calculation to use to properly position it every time. Do I take screen resolution or pixelsperinch into consideration?

    What I tried to do was this:

    So it seems like I could do the above, but maybe I need a better calculation for the (BOLD) areas.

    Maybe I am going about this wrong, but it just seems like this would be the way to do it.

    And to be honest my test does pretty good, but for the print routine that works with Ace Reports positions it higher so I am thinking I am not using the best calculation or not taking something into consideration.

    Using WPDF 2.x, WPTools 5.x, and Delphi 6.x

    We are using the WPDFPrinter to print multiple reports into a single PDF utilizing the BeginDoc / EndDoc.

    Every page is initiated with StartPage and ends with EndPage.

    What I want to do is create a two pass system where I can determine how many pages this document will be so I can inject a Page n of z at the bottom right of every page.

    What I would like to figure out is what math would I use and code to make it always print at the same position on all pages regardless of orientation. So essentially the text always starts at .35 inches above the bottom of the page and the right aligned text is always .35 inches to the left of the right side of the page...

    So I know I am using the Canvas.TextOut, but I am not sure of what to use to always put the text in the same area. I am guessing I would use the page width and page height values and subtracting some number to get the position to start the text.

    I am also not sure what to pass to make it right aligned (This isn't critical, but figured right aligning would be helpful). Most important issue is what math to get the same starting position.

    Using D6, wPDF 2.x, WPTools 5.x

    We are creating a PDF file from a TDBWPRichText.

    I know I can use the WPDFExport and it works fine. The WPRichText is properly printed to PDF and looks the same as the screen.

    HOWEVER in our case we are printing to PDF from two different reports. One is from Ace Reports and the other is from WPRichText.

    So I created a class that inherits from the TWPPDFPrinter and contains several overload methods called MakePDF. One handles the Ace Reports, one handles FastReports, one handles QuickReports and one handles WPTools WPRichText components.

    So I simply do the following:

    Code
    .. Do some report prep work    Print2WPDFObj := TPrint2WPDF.Create(Self);    Print2WPDFObj.Filename := 'C:\Subcontract.pdf';    Print2WPDFObj.CompressStreamMethod := wpCompressFastFlate;    Print2WPDFObj.AutoLaunch := True;    Print2WPDFObj.BeginDoc;    Print2WPDFObj.MakePDF(aAceReport);    Print2WPDFObj.MakePDF(aFastReport);    Print2WPDFObj.MakePDF(aQuickReport);    Print2WPDFObj.MakePDF(aWPRichText);    Print2WPDFObj.EndDoc;

    When I look at the output so far all reports look correct except for the WPRichText report. Since this works when I use the WPDFExport then I must be doing something wrong when I use the Print2WPDFObj based on the TWPPDFPrinter. You may ask why I don't use the WPDFExport. Basically because I can't see a way to have all 4 different report types above printed with WPDF into a single document. Anytime I introduced the WPDFExport it seemed to prevent me from having all reports append to each other as expected. So I needed to do everything from the WPPDFPrinter.

    So here is the code for the MakePDF when tied to the WPRichText:

    Code
    procedure TPrint2WPDF.MakePDF(aWPRichText: TWPRichText);var  i,w,h : Integer;begin  CanvasReference := wprefScreen;  i := 0;  while i < aWPRichText.CountPages do  begin    w := aWPRichText.Memo.PaintPageWidth[i];    h := aWPRichText.Memo.PaintPageHeight[i];    StartPage(MulDiv(w, Screen.PixelsPerInch, Screen.PixelsPerInch),              MulDiv(h, Screen.PixelsPerInch, Screen.PixelsPerInch),              Screen.PixelsPerInch, Screen.PixelsPerInch, 0);    try      // Use 0 as w and h to let the function calculate the width and height      aWPRichText.Memo.PaintRTFPage(i,0,0,0,0,Canvas, [wppInPaintForwPDF] );    finally      EndPage;    end;    inc(i);  end;end;

    My only guess is the height, width, or Startpage method must not be correctly being used.

    I end up with a page size of 7.67 x 6.97in for first page.
    I end up with a page size of 7.67 x 1.42in for second page.

    but with the WPDFExport

    I end up with a page size of 8.5 x 11in for first and second page as expected.

    It is possible the problem is due to changes in the WPRichText before printing takes place, but it doesn't cause a problem for the preview tool or the wpdfexport, but is an issue for the wpdfprinter as used above.

    Here is what happens right before printing... basically it is prepping header and footer text. This code is what was put in place by co-worker a long while back:

    Code
    CurrentAppendix := DBWPRTAppendix.DataField;  DBWPRTAppendix.DataField := 'AppendixA';  DBWPRTAppendix.ReadOnly := False;  DBWPRTAppendix.ClearHeaderFooter;  if (NOT DBWPRTAppendix.isEmpty) then  begin    // Begin Header    DBWPRTAppendix.HeaderFooterTextRange := wpraOnAllPages;    DBWPRTAppendix.WorkOnText := wpIsHeader;    DBWPRTAppendix.CurrAttr.Alignment := paralCenter;    DBWPRTAppendix.CurrAttr.DeleteStyle([afsUnderline]);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsItalic]);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsStrikeOut]);    DBWPRTAppendix.CurrAttr.AddStyle([afsBold]);    DBWPRTAppendix.CurrAttr.Size := 16;    if DBWPRTAppendix.DataField = 'AppendixA' then      DBWPRTAppendix.InputString('Appendix "A"');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsBold]);    DBWPRTAppendix.CurrAttr.Size := 12;    DBWPRTAppendix.InputMergeField('ProjectRE', 'ProjectRE');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputMergeField('CompanyName', 'CompanyName');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.CurrAttr.Alignment := paralRight;    DBWPRTAppendix.InputMergeField('CorresDateHeader', 'CorresDateHeader');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputString('Page ');    DBWPRTAppendix.InputTextFieldName('PAGE'); // current page    DBWPRTAppendix.InputString(' of ');    DBWPRTAppendix.InputTextFieldName('NUMPAGES');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.CurrAttr.Alignment := paralCenter;    // if not dmContract.isCanUserPrintFinal then// SCOOTER ADDED SO CONTRACT ADMINS CAN PRINT DRAFT COPIES TOO    if (NOT dmContract.DoPrintAsExecuted) then    begin      DBWPRTAppendix.InputString('This is NOT a Legal Document! ');      DBWPRTAppendix.InputString('Internal Office Use Only!');      DBWPRTAppendix.InputString(#13);      DBWPRTAppendix.InputString(#13);    end;    DBWPRTAppendix.MergeText;    // End Header    DBWPRTAppendix.WorkOnText := wpIsBody;    // Begin Blank Footer    DBWPRTAppendix.HeaderFooterTextRange := wpraOnAllPages;    DBWPRTAppendix.WorkOnText := wpIsFooter;    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.InputString(#13);    // End Blank Footer    DBWPRTAppendix.WorkOnText := wpIsBody;    //Footer    DBWPRTAppendix.HeaderFooterTextRange := wpraOnLastPage;    DBWPRTAppendix.WorkOnText := wpIsFooter;    DBWPRTAppendix.CurrAttr.DeleteStyle([afsUnderline]);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsItalic]);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsStrikeOut]);    DBWPRTAppendix.CurrAttr.AddStyle([afsBold]);    DBWPRTAppendix.CurrAttr.Size := 12;    DBWPRTAppendix.CurrAttr.Alignment := paralCenter;    if DBWPRTAppendix.DataField = 'AppendixA' then      DBWPRTAppendix.InputString('End of Appendix "A"');    DBWPRTAppendix.InputString(#13);    DBWPRTAppendix.CurrAttr.DeleteStyle([afsBold]);    DBWPRTAppendix.CurrAttr.Alignment := paralLeft;    DBWPRTAppendix.CurrAttr.Size := 11;    //End Footer    DBWPRTAppendix.WorkOnText := wpIsBody;    DBWPRTAppendix.ReformatAll(True,True);

    So do you see any issues here as to why the page size is not properly?

    Well... I have my own answer. I examined the WPDFExport code and found settings used there and got the following changes:

    I see the WPDFExport has other things dealing with ConvertJPEGData, ConvertMetafiltToBitMaps, CreateOutlines, CreateThmbnails that I don't take account for with the WPDFPrinter usage, but I am sure I could build that in at a later time.

    Right now being able to bring together the different report types we have used throughout various applications was of good use.

    One last thing... if there is a way to use the WPDFPrinter for the various report types and still use the WPDFExport for WPTools all the while keeping it all tied to the same BeginDoc / EndDoc so it is still one PDF after printing from multiple report types then please enlighten.