Sorry I view the wrong pdf file:
the incorrect header is
<<
/Type/Page
/Parent 7 0 R
/Resources 8 0 R
/MediaBox [0 0 703 994]
/Contents 13 0 R
>>
Sorry I view the wrong pdf file:
the incorrect header is
<<
/Type/Page
/Parent 7 0 R
/Resources 8 0 R
/MediaBox [0 0 703 994]
/Contents 13 0 R
>>
I use metafiles to be drawn on the pdf printer.
The size of the metafile is always 1122 (Height) and 794 (Width)
(initilaized through this code: metaFile.Width := MulDiv(PageHeight, 96, 1440);)
When printing on different computers this gives different page sizes
in the pdf file. In one case it is correct (297x210mm) on other computers
it is too small or too big.
I've here the tags I think are responsible for the width and height of the
pdf docs:
Incorrect (on my test computer; 279x215mm):
/Type/Page
/Parent 7 0 R
/Resources 8 0 R
/MediaBox [0 0 612 792]
Correct (on my own computer; 297x210mm):
/Type/Page
/Parent 7 0 R
/Resources 8 0 R
/MediaBox [0 0 598 839]
/Contents 13 0 R
/Contents 5 0 R
We got a workaround for this using
PDFPrinter.DrawMetafileEx(0, 0,
round(Metafile.Width / 96 * 72),
round(Metafile.Height / 96 * 72),
metaFile.Handle,96,96);
But I think it's not very clean.
any help??
best regards
Mike
Hello all!
I found a way myself using InputString( #12 ); and Refresh;
searching in previos postings in this newsgroup.
best regards
Mike
Sometimes in my project it is necessary to insert a page break so that headers are next to some graphic objects. I know there is ParKeep but this is not sufficient for me. So how can I insert a page break at the current cursor position?
best regards
Mike
I use in my projects this command:
PrintPageOnCanvas(ToCanvas, outRect, counter, [ppmUseBorders] ,100);
This method is a member of TWPRichText so take a look at it!
regards
Mike
I just tried to print a mm grid using standard VCL code. It appears that
using stretched metafiles the grid is 1mm smaller on 10cm which is not sufficient.
Pherhaps someone has any ideas...
best regards
Mike
I use to print to Canvas method to print a TWPRichText page on a metafile canvas and then print this metafile either to a PDF file or a printer. This eases for us the functionality to provide a mm-Paper on the screen/printer and reduces the lines to be drawn (and there are plenty of them!).
The only thing is now, how can I preserve that 5mm on the screen is the same as 5mm on the printout. The best I achieved is nearly 5mm but on other systems this method fails.
Here is the code I use:
// logx, logy are PixPerInch from the screen
metaFile.Width := MulDiv( Printer.PageWidth + 2*GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETX ),
logx, GetDeviceCaps( Printer.Canvas.Handle, LOGPIXELSX ) );
metaFile.Height := MulDiv( Printer.PageHeight + 2*GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETY ),
logx, GetDeviceCaps( Printer.Canvas.Handle, LOGPIXELSY ) );
outRect := Rect(-GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETX ),
-GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETY ),
Printer.PageWidth + GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETX ),
Printer.PageHeight + GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETY) );
metaFileCanvas := TMetafileCanvas.Create(metaFile, 0);
try
WPRichText1.PrintPageOnCanvas(metaFileCanvas, r, counter, [ppmUseEvents, ppmUseBorders] ,100);
finally
metaFileCanvas.Free;
end;
// Print the metafile to the printer
Printer.Canvas.StretchDraw(outRect,metaFile);
Is there something I'm missing??
regards
Mike
When I store the metafiles, the footer line is visible but cropped from the pdf!
best regards
Mike
I didn't mean the addionaly lines, they do not bother me. I meant the
rows itself. They look like as if they were merged from two tables
(the lines between the rows are double the size than lines between columns!!). You can easily test it by opening a html document with a table.
When opening a html document with the demo editor I must disable the
upper and lower borders for each second line to get the linewidth corrected (but the spacing is then a little crummy...)
I there something I could easily do?
best regards
Mike
For our reporting tool we have to insert tables and do this using HTML tables. The thing is that WPTools seem to add for each row a new table and this leads to doubled lines on the output!
How can this be circumvented?
best regards
Mike
Thanks that was exactly what I needed!!!
I changed some things and now the footer does not disapear anymore in the pdf. I figured out that some of my components did clip some area and that clipping was the reason for the disapearing footers.
But one problem is still there: The footer does not disapear any more but the breaking line between document and footer is not visible on the pdf -
document.
So what did you mean by changing the reference printer? How can I tell TWPRichText that I want to print a pdf file??
best regards
Mike
Addionaly I will post my printing code:
metaFile := TMetafile.Create;
try
// ######################################
// #### Prepare printing
if not DoPdf then
begin
Printer.Title := sPrintCaption;
Printer.BeginDoc;
end else
PDFPrinter.BeginDoc;
try
// ######################################
// #### prepare intermediate printing
// Create Metafile for this page with properties like the selected
// Paper
scrDC := GetDC(0);
logx := GetDeviceCaps(scrDC, LOGPIXELSX);
logy := GetDeviceCaps(scrDC, LOGPIXELSY);
// Calc physical properties
with WPRichText1.Header do
begin
metaFile.Height := MulDiv(PageHeight, logy, 1440);
metaFile.Width := MulDiv(PageWidth, logx, 1440);
ReleaseDC(0, scrDC);
end;
// read physical margins; I think WPTools respects the physical margins
// one time too often when printing to a canvas so I set the output
// the margins to their negative values
if not DoPdf then
begin
with Printer.Canvas do
begin
// All values are returned in Printer pixels!
physicalMargins.Top := -GetDeviceCaps(Handle, PHYSICALOFFSETY);
physicalMargins.Left := -GetDeviceCaps(Handle, PHYSICALOFFSETX);
physicalMargins.Bottom := GetDeviceCaps(Handle, PHYSICALHEIGHT) -
GetDeviceCaps(Handle, PHYSICALOFFSETY);
physicalMargins.Right := GetDeviceCaps(Handle, PHYSICALWIDTH) -
GetDeviceCaps(Handle, PHYSICALOFFSETX);
end;
outRect := physicalMargins;
end else
// The pdf uses the screen resolution so the outRect is the same as the metafile dimensions
outRect := Rect( 0, 0, metaFile.Width, metaFile.Height );
// rectangle the richt text shall print
r := Rect(0, 0, metaFile.Width, metaFile.Height);
// ##############################################
// ##### Print
for counter:=0 to WPRichText1.CountPages-1 do
begin
// for pdf every page must be extra started
if DoPdf then
PDFPrinter.StartPage( metafile.Width, metafile.Height, Screen.PixelsPerInch,Screen.PixelsPerInch, 0 );
metaFileCanvas := TMetafileCanvas.Create(metaFile, 0);
try
// Print to canvas, based on screen resolution
WPRichText1.PrintPageOnCanvas(metaFileCanvas, r, counter, [ppmUseEvents, ppmUseBorders] ,100);
finally
metaFileCanvas.Free;
end;
if not DoPdf then
begin
// Print the metafile to the printer
Printer.Canvas.StretchDraw(outRect, metaFile);
if counter<>WPRichText1.CountPages-1 then
Printer.NewPage;
end else
begin
PDFPrinter.Canvas.Draw(0, 0, metaFile );
PDFPrinter.EndPage;
end;
end;
finally
// Finalize document
if not DoPdf then
Printer.EndDoc
else
PDFPrinter.EndDoc;
end;
finally
metaFile.Free;
end;
end;
Alles anzeigen
We want to have the default cell height to be smaller to get more lines per page. I found three properties regarding paragraphs: CurrAttr.SpaceBetween, CurrAttr.SpaceAfter, CurrAttr.SpaceBefore.
Are these properties the only one to change a cell height or did I oversee something?
best regards
Mike
I use the same routine to print pdfs (using TWPPDFPrinter) and
normal documents on a printer. At first I put everything on a Metafile using PrintPageOnCanvas of the TWPRichText object then print it to the printer. The thing is that sometimes the
footer just disapears (or just the breaking line) and the output of
footers is different using one time the pdf printer and one time the
normal printer.
Any help??
best regards
Mike
That doesn't seem to do anything!
My problem is that when printing with custom code and using some sort of right alligned text the text is clipped a few pixels (that comes often when I use Page x/y right alligned in a footer). It does not appear when using a right alligned tab or printing with the built in print routine!
What must I do to get non clipped printings??
I use following code to print pages on a metafile and then to a printer
scrDC := GetDC(0);
logx := GetDeviceCaps(scrDC, LOGPIXELSX);
logy := GetDeviceCaps(scrDC, LOGPIXELSY);
with WPRichText1.Header do
begin
metaFile.Height := MulDiv(PageHeight, logy, 1440);
metaFile.Width := MulDiv(PageWidth, logx, 1440);
ReleaseDC(0, scrDC);
end;
// read physical margins
with Printer.Canvas do
begin
// All values are returned in Printer pixels!
physicalMargins.Top := GetDeviceCaps(Handle, PHYSICALOFFSETY);
physicalMargins.Left := GetDeviceCaps(Handle, PHYSICALOFFSETX);
physicalMargins.Bottom := GetDeviceCaps(Handle, PHYSICALHEIGHT) -
2*GetDeviceCaps(Handle, PHYSICALOFFSETY);
physicalMargins.Right := GetDeviceCaps(Handle, PHYSICALWIDTH) -
2*GetDeviceCaps(Handle, PHYSICALOFFSETX);
end;
// rectangle the richt text shall print
r := Rect(0, 0, metaFile.Width, metaFile.Height);
// respect physical margins: Left, Right margin and the margins of the header/footer
outRect := physicalMargins;
// ##############################################
// ##### Print
for counter:=0 to WPRichText1.CountPages-1 do
begin
metaFileCanvas := TMetafileCanvas.Create(metaFile, 0);
try
// Print to canvas, based on screen resolution
WPRichText1.PrintPageOnCanvas(metaFileCanvas, r, counter, [ppmUseEvents, ppmUseBorders] ,100);
finally
metaFileCanvas.Free;
end;
// Print the metafile to the printer
Printer.Canvas.StretchDraw(outRect, metaFile);
if counter<>WPRichText1.CountPages-1 then
Printer.NewPage;
end;
finally
Printer.EndDoc;
end;
finally
metaFile.Free;
end;
Alles anzeigen