You are not logged in.
Pages: 1
I am sorry I don't understand what you are saying. Can you change the above code to work? Thanks for your help.
I want the document to have 600 DPI and to be 8 inches wide x 50 inches long. This is what I currently have. Nothing is printed on the page.
lPdf := TPdfDocumentGDI.Create;
try
lPdf.ScreenLogPixels:=600;
lPdf.DefaultPageHeight := lPdf.ScreenLogPixels * 50; // Since ScreenLogPixels holds the number of pixels per inch this should give me a 50 inch long page.
lPdf.DefaultPageWidth := lPdf.ScreenLogPixels * 8; // Same here with Page being 8 inches wide.
// When viewing the document in Adobe Reader the page height and width 66.67 x 200.00 with nothing displayed
// If I comment out the ScreenLogPixels line the page size becomes 10.67 x 66.67 with a pixel count of 768 x 4800 with the proper text on the document.
lPage := lPDF.AddPage;
lPdf.VCLCanvas.Brush.Style:=bsClear;
MyY:=300;
lPDF.VCLCanvas.TextOut(100, 100, 'Width = ' + IntToStr(lPage.PageWidth) +
' Height = ' + IntToStr(lPage.PageHeight));
for MyX := 1 to 400 do begin
MyXLoc:=(MyX*120) mod (lPage.PageWidth);
MyString:=IntToStr(MyX);
lPDF.VCLCanvas.TextOut(MyXLoc, MyY, Mystring);
lPDF.VCLCanvas.Font.Size:= lPDF.VCLCanvas.Font.Size+4;
lPDF.VCLCanvas.Rectangle(MyXLoc, MyY, MyXLoc+lPDF.VCLCanvas.TextWidth(MyString), MyY+lPDF.VCLCanvas.TextHeight(MyString));
MyY := MyY + lPDF.VCLCanvas.TextHeight(MyString);
end;
lPdf.SaveToFile('c:\Syntest.pdf');
finally
lPdf.Free;
end;
If I move the setting of page height/width before calling AddPage I get a run time error stating that lPage is not initialized. How do I create the page?
I got the sample PDF file working. However, I need to be able to change the height of the page based upon the document that I am creating. This page may be as long as 50 inches in length. When changing the height of the page in the example program all printing disappears from the page. Here is the code I am using:
lPdf.ScreenLogPixels:=600;
lPage := lPDF.AddPage;
lPage.PageHeight := lPdf.ScreenLogPixels * 50; // This is the added line. If I remove this everything is displayed on the page.
lPdf.VCLCanvas.Brush.Style:=bsClear;
MyY:=300;
for MyX := 1 to 40 do begin
MyXLoc:=(MyX*120) mod lPage.PageWidth;
MyString:=IntToStr(MyX);
lPDF.VCLCanvas.TextOut(MyXLoc, MyY, Mystring);
lPDF.VCLCanvas.Font.Size:= lPDF.VCLCanvas.Font.Size+4;
lPDF.VCLCanvas.Rectangle(MyXLoc, MyY, MyXLoc+lPDF.VCLCanvas.TextWidth(MyString), MyY+lPDF.VCLCanvas.TextHeight(MyString));
MyY := MyY + lPDF.VCLCanvas.TextHeight(MyString);
end;
lPdf.SaveToFile('c:\Syntest.pdf');
Pages: 1