i am trying to use the synpdf package to directly build pdf documents.
I started out using Foxit reader as the default viewer and from that i got nice results and no errors.
Unfortunately i have to use Adobe reader 9 as the default viewer and document printer.
It shows and prints the document perfectly, but always with the popup saying that there are some errors in the document.
First the error popup also came when opening the document and displaying it on screen, but when i changed it to clipped text output, the message did not come again.
I have still the problem that even putting in one line of text produces an error in adobe reader 9 when printing the document.
I browsed all sources and examples and cannot seem to find a simple example of how to use synpdf directly and correctly.
Is there a simple sample pascal example in which a document is generated with some text and some line graphics ?
Put your code here, and we'll see what's wrong.
I have Adobe Reader 9 installed on my computer, and no error message. What is your error message?
Perhaps you have downloaded an old version of the code. I corrected such an error weeks ago.
The easiest way of using SynPdf is to use a TPdfDocumentGDI, and its VCLCanvas property. So you draw on every page with the same TCanvas as usual for other VCL. Code will be a little bigger, but the resulting pdf will be optimized.
The only possible problem of using VCLCanvas is if you're using a lot of similar images in the pdf (like a background image or a logo on every page). It's therefore preferred to create an unique TPdfImage, then use directly the Canvas property and its DrawXObject / DrawXObjectEx method.
See TPdfEnum.DrawBitmap on how to create these low-level TPdfImage instance from Bmp or Jpeg.
first i want to thank you for taking your time on this, much appreciated.
this is a very small piece that already makes adobe reader giving the message when printing ( it is to a postscript printer , maybe that gives a clue ).
procedure TForm5.Button1Click(Sender: TObject); var lPdf : TPdfDocument; lPage : TPdfPage; begin lPdf := TPdfDocument.Create; try lPdf.Info.Author := 'Tester'; lPdf.Info.CreationDate := Now; lPdf.Info.Creator := 'Tester'; lPdf.DefaultPaperSize := psA4; lPage := lPDF.AddPage; lPDF.Canvas.SetFont('Helvetica',10.0,); lPDF.Canvas.SetLeading(lPDF.Canvas.Page.FontSize); lPDF.Canvas.SetLineWidth(0.1); lPdf.Canvas.BeginText; lPdf.Canvas.TextOut( 300, 700, 'This is some text.'); lPdf.Canvas.EndText; lPdf.SaveToFile('c:\temp\test.pdf'); finally lPdf.Free; end; end;
I use exactly the same example but in additional a rectangle and a moveto/lineto.
I doesn't work or I can't see it in the pdf.
Is there an initialistion code before?
What I do wrong?
This above code works as is, with my current version from Source Code repository.
Don't know what's wrong here.
Perhaps you're using an old version, and the "Helvetica" font is not available on your PC.
In current revision, "Helvetica" is changed into "Arial".
And there is a fallback font to "Arial" if the font name is incorrect.
I had the same problem - removed BeginText and EndText and it worked.
Hope it works.
Indeed: the TextOut() method already add the BT / ET command, so the BeginText and EndText are unexpected.
You made a confusion between TextOut() and ShowText().
As I wrote above, the easiest way of using SynPdf is to use a TPdfDocumentGDI, and its VCLCanvas property. So you draw on every page with the same TCanvas as usual for other VCL. Code will be a little bigger, but the resulting pdf will be optimized, and not noticeably slower to generate.
With a VCL TCanvas, you won't be confused by low-level PDF commands like BeginText/EndText.